end
rescue ActionView::TemplateError => ex
if ex.original_exception.is_a?(Timeout::Error)
- render :action => "timeout", :status => :request_timeout
+ render :action => "timeout"
else
raise
end
rescue Timeout::Error
- render :action => "timeout", :status => :request_timeout
+ render :action => "timeout"
end
end
end
def languages
- attribute_present?(:languages) ? read_attribute(:languages).split(",") : []
+ attribute_present?(:languages) ? read_attribute(:languages).split(/ *, */) : []
end
def languages=(languages)
-<p class="search_results_error"><%= @error %></p>
+<p class="search_results_error"><%= h(@error) %></p>
}
function updateMapKey() {
- var layer = map.baseLayer.name.toLowerCase().replace(/\s+/g, "_");
+ var layer = map.baseLayer.keyid;
var zoom = map.getZoom();
<%= remote_function :update => "sidebar_content",
--- /dev/null
+database.yml
config.gem 'httpclient'
config.gem 'SystemTimer', :version => '>= 1.1.3', :lib => 'system_timer'
config.gem 'sanitize'
- # if Rails.env == "development"
- config.gem 'timecop'
- # end
# Only load the plugins named here, in the order given. By default, all plugins
# in vendor/plugins are loaded in alphabetical order.
# The :test delivery method accumulates sent emails in the
# ActionMailer::Base.deliveries array.
config.action_mailer.delivery_method = :test
+
+# Load timecop to help with testing time dependent code
+config.gem 'timecop'
# Export driver: syck
# Author: Aude
# Author: Bassem JARKAS
+# Author: Grille chompa
# Author: Mutarjem horr
# Author: OsamaK
ar:
water_point: نقطة ماء شفة
waterfall: شلال
weir: هدار (سدّ منخفض)
+ html:
+ dir: rtl
javascripts:
map:
base:
title: Conjunt de canvis
changeset_details:
belongs_to: "Pertany a:"
+ bounding_box: "Caixa contenidora:"
box: caixa
closed_at: "Tancat el:"
created_at: "Creat el:"
cliff: Cingle
coastline: Litoral
crater: Cràter
+ fell: Forest
fjord: Fiord
geyser: Guèiser
glacier: Glacera
peak: Pic
point: Punt
reef: Escull
+ ridge: Cresta
river: Riu
rock: Roca
scree: Pedregar
shoal: Banc
spring: Deu
+ strait: Estret
tree: Arbre
valley: Vall
volcano: Volcà
country: País
county: Comtat
farm: Granja
+ hamlet: Aldea
house: Casa
houses: Cases
island: Illa
viewpoint: Mirador
zoo: Zoològic
waterway:
+ canal: Canal
ditch: Séquia
mooring: Amarradors
rapids: Ràpids
ago: (fa {{time_in_words_ago}})
confirm: Confirmeu
create_block: boca aquest usuari
+ created from: "Creat a partir de:"
deactivate_user: desactiva aquest usuari
delete_user: Suprimeix aquest usuari
description: Descripció
no_apps: Wenn du mit einer Anwendung gerne den {{oauth}}-Standard verwenden würdest, musst du sie hier registrieren.
register_new: Anwendung registrieren
registered_apps: "Du hast die folgenden Client-Anwendungen registriert:"
- revoke: Wiederrufen!
+ revoke: Widerrufen!
title: Meine OAuth Details
new:
submit: Registrieren
node: Näytä piste suurella kartalla
relation: Näytä relaatio suurella kartalla
way: Näytä polku suurella kartalla
- loading: Lataa tietoja...
+ loading: Ladataan…
node:
download: "{{download_xml_link}}, {{view_history_link}} tai {{edit_link}}"
download_xml: Lataa XML
load_data: Cargar os datos
loaded_an_area_with_num_features: Cargou unha zona que contén [[num_features]] funcionalidades. Pode que algúns navegadores teñan problemas para amosar correctamente esta cantidade de datos. Xeralmente, os navegadores traballan mellor amosando menos de 100 funcionalidades á vez. Utilizar máis pode provocar que o navegador vaia lento ou non responda. Se está seguro de que quere amosar estes datos, pode facelo premendo no seguinte botón.
loading: Cargando...
- manually_select: Escolla manualmente unha zona distinta
+ manually_select: Escoller manualmente unha zona distinta
object_list:
api: Obter esta área desde o API
back: Mostrar a lista de obxectos
save_button: Gardar
export:
start:
+ add_marker: Engadir un marcador ao mapa
area_to_export: Zona a exportar
export_button: Exportar
format: Formato
mapnik_image: Imaxe de Mapnik
max: máx.
options: Opcións
+ osm_xml_data: Datos XML do OpenStreetMap
scale: Escala
+ too_large:
+ body: Esta zona é grande de máis para ser exportada como datos XML do OpenStreetMap. Amplíe a zona ou escolla unha menor.
+ heading: Zona demasiado grande
zoom: Zoom
start_rjs:
+ add_marker: Engadir un marcador ao mapa
+ change_marker: Cambiar a posición do marcador
+ click_add_marker: Prema sobre o mapa para engadir un marcador
+ drag_a_box: Arrastre unha caixa sobre o mapa para escoller unha zona
export: Exportar
+ manually_select: Escoller manualmente unha zona distinta
+ view_larger_map: Ver un mapa máis grande
geocoder:
description:
title:
geonames: Localización desde <a href="http://www.geonames.org/">GeoNames</a>
osm_namefinder: "{{types}} desde <a href=\"http://gazetteer.openstreetmap.org/namefinder/\">OpenStreetMap Namefinder</a>"
+ osm_nominatim: Localización desde <a href="http://nominatim.openstreetmap.org/">OpenStreetMap Nominatim</a>
types:
cities: Cidades
places: Lugares
towns: Municipios
+ description_osm_namefinder:
+ prefix: "{{distance}} ao {{direction}} de {{type}}"
direction:
east: leste
north: norte
south_east: sueste
south_west: suroeste
west: oeste
+ distance:
+ one: arredor de 1km
+ other: arredor de {{count}}km
+ zero: menos de 1km
results:
more_results: Máis resultados
no_results: Non se atopou ningún resultado
geonames: Resultados desde <a href="http://www.geonames.org/">GeoNames</a>
latlon: Resultados <a href="http://openstreetmap.org/">internos</a>
osm_namefinder: Resultados desde <a href="http://gazetteer.openstreetmap.org/namefinder/">OpenStreetMap Namefinder</a>
+ osm_nominatim: Resultados desde <a href="http://nominatim.openstreetmap.org/">OpenStreetMap Nominatim</a>
uk_postcode: Resultados desde <a href="http://www.npemap.org.uk/">NPEMap / FreeThe Postcode</a>
us_postcode: Resultados desde <a href="http://geocoder.us/">Geocoder.us</a>
+ search_osm_namefinder:
+ suffix_parent: "{{suffix}} ({{parentdistance}} {{parentdirection}} de {{parentname}})"
+ suffix_place: ", {{distance}} ao {{direction}} de {{placename}}"
+ search_osm_nominatim:
+ prefix:
+ highway:
+ emergency_access_point: Punto de acceso de emerxencia
+ footway: Carreiro
+ motorway_junction: Cruce de autovías
+ primary_link: Estrada principal
+ secondary_link: Estrada secundaria
+ leisure:
+ beach_resort: Balneario
+ common: Terreo común
+ fishing: Área de pesca
+ garden: Xardín
+ golf_course: Campo de golf
+ ice_rink: Pista de patinaxe sobre xeo
+ marina: Porto deportivo
+ miniature_golf: Minigolf
+ nature_reserve: Reserva natural
+ park: Parque
+ pitch: Cancha deportiva
+ playground: Patio de recreo
+ recreation_ground: Área recreativa
+ slipway: Varadoiro
+ sports_centre: Centro deportivo
+ stadium: Estadio
+ swimming_pool: Piscina
+ track: Pista de carreiras
+ water_park: Parque acuático
+ natural:
+ bay: Baía
+ beach: Praia
+ cape: Cabo
+ cave_entrance: Entrada de cova
+ channel: Canal
+ cliff: Cantil
+ coastline: Litoral
+ crater: Cráter
+ feature: Elemento
+ fell: Brañal
+ fjord: Fiorde
+ glacier: Glaciar
+ hill: Outeiro
+ island: Illa
+ land: Terra
+ marsh: Marisma
+ moor: Páramo
+ mud: Lama
+ peak: Pico
+ point: Punto
+ reef: Arrecife
+ river: Río
+ rock: Rocha
+ scree: Pedregal
+ shoal: Cardume
+ spring: Primavera
+ strait: Estreito
+ tree: Árbore
+ valley: Val
+ volcano: Volcán
+ water: Auga
+ wetland: Pantano
+ wetlands: Pantano
+ wood: Bosque
+ place:
+ airport: Aeroporto
+ city: Cidade
+ country: País
+ county: Condado
+ farm: Granxa
+ hamlet: Aldea
+ house: Casa
+ houses: Casas
+ island: Illa
+ islet: Illote
+ locality: Localidade
+ moor: Páramo
+ municipality: Municipio
+ postcode: Código postal
+ region: Rexión
+ sea: Mar
+ state: Estado/Provincia
+ subdivision: Subdivisión
+ suburb: Barrio
+ town: Cidade
+ unincorporated_area: Área non incorporada
+ village: Vila
+ tourism:
+ alpine_hut: Cabana alpina
+ artwork: Obra de arte
+ attraction: Atracción
+ bed_and_breakfast: Cama e almorzo
+ cabin: Cabana
+ camp_site: Campamento
+ caravan_site: Sitio de caravanas
+ chalet: Chalé
+ guest_house: Albergue
+ hostel: Hostal
+ hotel: Hotel
+ information: Información
+ lean_to: Caseta
+ motel: Motel
+ museum: Museo
+ picnic_site: Sitio de pícnic
+ theme_park: Parque temático
+ valley: Val
+ viewpoint: Miradoiro
+ zoo: Zoolóxico
layouts:
edit: Editar
export: Exportar
subject: Asunto
sent_message_summary:
delete_button: Borrar
+ notifier:
+ email_confirm:
+ subject: "[OpenStreetMap] Confirme o seu enderezo de correo electrónico"
oauth_clients:
edit:
submit: Editar
+ title: Editar a súa aplicación
+ index:
+ application: Nome da aplicación
+ register_new: Rexistrar a súa aplicación
time:
formats:
friendly: "%e %B %Y ás %H:%M"
save_button: Gardar os cambios
start_coord: "Coordenada de inicio:"
tags: "Etiquetas:"
+ tags_help: separadas por comas
uploaded_at: "Cargado o:"
visibility: "Visibilidade:"
visibility_help: que significa isto?
description: Descrición
help: Axuda
tags: Etiquetas
+ tags_help: separadas por comas
upload_button: Cargar
visibility: Visibilidade
visibility_help: que significa isto?
current email address: "Enderezo de correo electrónico actual:"
delete image: Eliminar a imaxe actual
email never displayed publicly: (nunca mostrado publicamente)
+ flash update success: Información de usuario actualizada correctamente.
+ flash update success confirm needed: Información de usuario actualizada correctamente. Busque no seu correo electrónico unha mensaxe para confirmar o seu novo enderezo.
home location: "Lugar de orixe:"
image: "Imaxe:"
keep image: Manter a imaxe actual
return to profile: Voltar ao perfil
save changes button: Gardar os cambios
title: Editar a conta
+ update home location on click: Quere actualizar o domicilio ao premer sobre o mapa?
confirm:
button: Confirmar
+ failure: Xa se confirmou unha conta de usuario con este pase.
heading: Confirmar unha conta de usuario
press confirm button: Prema sobre o botón de confirmación que aparece a continuación para activar a súa conta.
+ success: Confirmouse a súa conta. Grazas por se rexistrar!
confirm_email:
button: Confirmar
+ failure: Xa se confirmou un enderezo de correo electrónico con este pase.
+ heading: Confirmar o cambio do enderezo de correo electrónico
press confirm button: Prema sobre o botón de confirmación que aparece a continuación para confirmar o seu novo enderezo de correo electrónico.
+ success: Confirmouse o seu enderezo de correo electrónico. Grazas por se rexistrar!
filter:
not_an_administrator: Ten que ser administrador para poder levar a cabo esta acción.
login:
+ create_account: cree unha conta
email or username: "Enderezo de correo electrónico ou nome de usuario:"
lost password link: Perdeu o seu contrasinal?
password: "Contrasinal:"
+ please login: Identifíquese ou {{create_user_link}}.
remember: "Lembrádeme:"
lost_password:
email address: "Enderezo de correo electrónico:"
heading: Esqueceu o contrasinal?
new password button: Restablecer o contrasinal
+ notice email cannot find: Non se puido atopar o enderezo de correo electrónico.
+ notice email on way: Por desgraza perdeuno, pero hai en camiño unha mensaxe de correo electrónico coa que o poderá restablecer axiña.
title: Contrasinal perdido
make_friend:
already_a_friend: Xa é amigo de {{name}}.
+ failed: Houbo un erro ao engadir a {{name}} como amigo.
success: "{{name}} xa é o seu amigo."
new:
confirm email address: Confirmar o enderezo de correo electrónico
confirm password: "Confirmar o contrasinal:"
display name: "Nome mostrado:"
+ display name description: O seu nome de usuario mostrado publicamente. Pode cambialo máis tarde nas preferencias.
email address: "Enderezo de correo electrónico:"
+ fill_form: Encha o formulario e axiña recibirá un correo electrónico coas instrucións para activar a súa conta.
heading: Crear unha conta de usuario
+ no_auto_account_create: Por desgraza, arestora non podemos crear automaticamente unha conta para vostede.
password: "Contrasinal:"
title: Crear unha conta
no_such_user:
+ body: Non existe ningún usuario co nome "{{user}}". Comprobe a ortografía ou que a ligazón que seguiu estea ben.
+ heading: O usuario {{user}} non existe
title: Non existe tal usuario
popup:
friend: Amigo
your location: A súa localización
+ remove_friend:
+ not_a_friend: "{{name}} non é un dos seus amigos."
+ success: "{{name}} foi eliminado dos seus amigos."
reset_password:
confirm password: "Confirmar o contrasinal:"
flash changed: Cambiouse o seu contrasinal.
+ flash token bad: Non se atopou o pase. Quizais debería comprobar o enderezo URL.
heading: Restablecer o contrasinal de {{user}}
password: "Contrasinal:"
reset: Restablecer o contrasinal
title: Restablecer o contrasinal
+ set_home:
+ flash success: Gardouse o domicilio
view:
activate_user: activar este usuario
add as friend: engadir como amigo
no friends: Aínda non engadiu ningún amigo.
oauth settings: axustes OAuth
remove as friend: eliminar como amigo
+ role:
+ administrator: Este usuario é administrador
+ grant:
+ administrator: Conceder o acceso de administrador
+ moderator: Conceder o acceso de moderador
+ moderator: Este usuario é moderador
+ revoke:
+ administrator: Revogar o acceso de administrador
+ moderator: Revogar o acceso de moderador
send message: enviar unha mensaxe
settings_link_text: axustes
unhide_user: descubrir este usuario
login:
account not active: Spiacenti, il tuo profilo non è ancora attivo.<br />Clicca sul collegamento presente nell'email di conferma per attivare il tuo profilo.
auth failure: Spiacenti, non si può accedere con questi dettagli.
- create_account: crea un profilo
+ create_account: crealo ora
email or username: "Indirizzo email o nome utente:"
heading: Entra
login_button: Entra
history_tooltip: Bewerkingen voor dit gebied bekijken
history_zoom_alert: U moet inzoomen om de kaart te bewerkingsgeschiedenis te bekijken
layouts:
- copyright: Auteursrechten & licentie
donate: Ondersteun OpenStreetMap door te {{link}} aan het Hardware Upgrade-fonds.
donate_link_text: doneren
edit: Bewerken
hopefully_you_1: Noen (forhåpentligvis deg) ønsker å endre e-postadressen for
hopefully_you_2: "{{server_url}} til {{new_address}}."
friend_notification:
+ befriend_them: Du kan også legge dem til som venn på {{befriendurl}}.
had_added_you: "{{user}} har lagt deg til som venn på OpenStreetMap."
see_their_profile: Du kan se profilen deres på {{userurl}}.
subject: "[OpenStreetMap] {{user}} la deg til som en venn"
signup_confirm_html:
click_the_link: Hvis dette er deg, så er du velkommen! Klikke lenka nedenfor for å bekrefte kontoen og les videre for mer informasjon om OpenStreetMap
current_user: En liste over nåværende brukere i kategorier, basert på hvor i verden de er, er tilgjengelig fra <a href="http://wiki.openstreetmap.org/wiki/Category:Users_by_geographical_region">Category:Users_by_geographical_region</a>.
+ get_reading: Start å lese om OpenStreetMap <a href="http://wiki.openstreetmap.org/wiki/Beginners%27_Guide">på wikien</a>, få med deg de siste nyhetene via <a href="http://blog.openstreetmap.org/">OpenStreetMap-bloggen</a> eller <a href="http://twitter.com/openstreetmap">Twitter</a>. Eller bla gjennom OpenStreetMaps grunnlegger Steve Coasts <a href="http://www.opengeodata.org/">OpenGeoData-blogg</a> for hele historien til prosjektet, som også har <a href="http://www.opengeodata.org/?cat=13">engelske podkaster</a> du kan lytte til.
greeting: Hei der!
hopefully_you: Noen (forhåpentligvis deg) ønsker å opprette en konto på
introductory_video: Du kan se en {{introductory_video_link}}.
site:
edit:
anon_edits_link_text: Finn ut hvorfor dette er tilfellet.
+ flash_player_required: Du trenger en Flash-spiller for å kunne bruke Potlatch, Flasheditoren for OpenStreetMap. Du kan <a href="http://www.adobe.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash">laste ned Flash Player fra Adobe.com</a>. <a href="http://wiki.openstreetmap.org/wiki/Editing">Flere andre alternativ</a> er også tilgjengelig for redigering av OpenStreetMap.
not_public: Du har ikke satt dine redigeringer til å være offentlige.
not_public_description: Du kan ikke lenger redigere kartet om du ikke gjør det. Du kan gjøre dine redigeringer offentlige fra din {{user_page}}.
potlatch_unsaved_changes: Du har ulagrede endringer. (For å lagre i Potlatch, må du fjerne markeringen av gjeldende vei eller punkt hvis du redigerer i live-modues eller klikke lagre hvis du har en lagreknapp.)
back: Vis alle blokkeringer
heading: Endrer blokkering av {{name}}
needs_view: Må brukeren logge inn før denne blokkeringen blir fjernet?
+ period: Hvor lenge, fra nå, brukeren vil bli blokkert fra API-en.
reason: Årsaken til hvorfor {{name}} blir blokkert. Vennligst vær så rolig og rimelig som mulig og oppgi så mange detaljer du kan om situasjonen. Husk at ikke alle brukere forstår felleskapssjargongen så prøv å bruke lekmannsuttrykk.
show: Vis denne blokkeringen
submit: Oppdater blokkering
back: Vis alle blokkeringer
heading: Oppretter blokkering av {{name}}
needs_view: Brukeren må logge inn før denne blokkeringen blir fjernet.
+ period: Hvor lenge, fra nå, brukeren vil bli blokkert fra API-en.
reason: Årsaken til at {{name}} blir blokkert. Vennligst vær så rolig og rimelig som mulig og gi så mange detaljer du kan om situasjonen, og husk på at meldingen blir synlig for offentligheten. Husk på at ikke alle brukere forstår fellesskapssjargongen så prøv å bruke lekmannsuttrykk.
submit: Opprett blokkering
title: Oppretter blokkering av {{name}}
tried_waiting: Jeg har gitt brukeren rimelig med tid til å svare på disse kommunikasjonene.
not_found:
back: Tilbake til indeksen
+ sorry: Beklager, brukerblokkeringen med ID {{id}} ble ikke funnet.
partial:
confirm: Er du sikker?
creator_name: Opprettet av
reply_link: Odgovori na ta vnos
edit:
body: "Besedilo:"
- language: "Jezki:"
+ language: "Jezik:"
latitude: "Z. širina:"
location: "Lokacija:"
longitude: "Z. dolžina:"
bicycle_rental: Chỗ Mướn Xe đạp
cafe: Quán Cà phê
car_rental: Chỗ Mướn Xe
+ car_sharing: Chia sẻ Xe cộ
car_wash: Tiệm Rửa Xe
casino: Sòng bạc
cinema: Rạp phim
university: Trường Đại học
waste_basket: Thùng rác
wifi: Điểm Truy cập Không dây
+ youth_centre: Trung tâm Thanh niên
boundary:
administrative: Biên giới Hành chính
building:
bunker: Boong ke
church: Nhà thờ
+ city_hall: Trụ sở Thành phố
commercial: Tòa nhà Thương mại
dormitory: Ký túc xá
entrance: Cửa vào
monorail: Đường Một Ray
station: Nhà ga
subway: Trạm Xe điện Ngầm
+ subway_entrance: Cửa vào Nhà ga Xe điện ngầm
tram: Đường Xe điện
shop:
bakery: Tiệm Bánh
bicycle: Tiệm Xe đạp
books: Tiệm Sách
+ car: Tiệm Xe hơi
car_dealer: Cửa hàng Xe hơi
car_repair: Tiệm Sửa Xe
carpet: Tiệm Thảm
fashion: Tiệm Thời trang
fish: Tiệm Cá
florist: Tiệm Hoa
+ food: Tiệm Thực phẩm
grocery: Tiệm Tạp phẩm
hairdresser: Tiệm Làm tóc
insurance: Bảo hiểm
waterway:
canal: Kênh
dam: Đập
+ rapids: Thác ghềnh
river: Sông
riverbank: Bờ sông
stream: Dòng suối
send_message_to: Gửi thư mới cho {{name}}
subject: Tiêu đề
title: Gửi thư
+ no_such_message:
+ body: Rất tiếc, không có thư nào với ID đó.
+ heading: Thư không tồn tại
+ title: Thư không tồn tại
no_such_user:
- body: Rất tiếc, không có người dùng hoặc thư với tên hoặc ID đó
- heading: Người dùng hoặc thư không tồn tại
- title: Người dùng hoặc thư không tồn tại
+ body: Rất tiếc, không có người dùng với tên đó.
+ heading: Người dùng không tồn tại
+ title: Người dùng không tồn tại
outbox:
date: Ngày
inbox: thư đến
hopefully_you_1: Ai (chắc bạn) muốn đổi địa chỉ thư điện tử bên
hopefully_you_2: "{{server_url}} thành {{new_address}}."
friend_notification:
+ befriend_them: Cũng có thể thêm họ vào danh sách người bạn tại {{befriendurl}}.
had_added_you: "{{user}} đã thêm bạn vào danh sách bạn tại OpenStreetMap."
- see_their_profile: Có thể xem trang cá nhân của họ tại {{userurl}} và cũng thêm họ vào danh sách của bạn tùy ý.
+ see_their_profile: Có thể xem trang cá nhân của họ tại {{userurl}}.
subject: "[OpenStreetMap] {{user}} đã thêm bạn là người bạn"
gpx_notification:
and_no_tags: và không có thẻ
sidebar:
close: Đóng
search_results: Kết quả Tìm kiếm
+ time:
+ formats:
+ friendly: "%e tháng %m năm %Y lúc %H:%M"
trace:
create:
trace_uploaded: Tập tin GPX của bạn đã được tải lên và đang chờ được chèn vào cơ sở dữ liệu. Thường chỉ cần chờ đợi trong vòng nửa tiếng, và bạn sẽ nhận thư điện tử lúc khi nó xong.
flash update success confirm needed: Đã cập nhật thông tin cá nhân thành công. Kiểm tra thư điện tử xác nhận địa chỉ thư điện tử mới.
home location: "Vị trí Nhà:"
image: "Hình:"
+ image size hint: (hình vuông ít nhất 100×100 điểm ảnh là tốt nhất)
keep image: Giữ hình hiện dùng
latitude: "Vĩ độ:"
longitude: "Kinh độ:"
lost password link: Quên mất Mật khẩu?
password: "Mật khẩu:"
please login: Xin hãy đăng nhập hoặc {{create_user_link}}.
+ remember: "Nhớ tôi:"
title: Đăng nhập
+ logout:
+ heading: Đăng xuất OpenStreetMap
+ logout_button: Đăng xuất
+ title: Đăng xuất
lost_password:
email address: "Địa chỉ Thư điện tử:"
heading: Quên mất Mật khẩu?
heading: Người dùng {{user}} không tồn tại
title: Người dùng không tồn tại
popup:
+ friend: Người bạn
nearby mapper: Người vẽ bản đồ ở gần
your location: Vị trí của bạn
remove_friend:
my edits: đóng góp của tôi
my settings: tùy chọn
my traces: tuyến đường của tôi
- nearby users: "Người dùng ở gần:"
+ nearby users: Người dùng khác ở gần
new diary entry: mục nhật ký mới
no friends: Bạn chưa thêm người bạn.
- no nearby users: Chưa có người dùng nào nhận là họ ở gần.
+ no nearby users: Không có người dùng nào nhận rằng họ ở gần.
+ oauth settings: Thiết lập OAuth
remove as friend: dời người bạn
role:
administrator: Người dùng này là quản lý viên
----\r
-log_file: log/mongrel.log\r
-port: 8000\r
-pid_file: tmp/mongrel.pid\r
+---
+log_file: log/mongrel.log
+port: 8000
+pid_file: tmp/mongrel.pid
servers: 8
\ No newline at end of file
option_layer_ooc_7th: "Regne Unit històric: 7th"
option_layer_ooc_npe: "Regne Unit històric: NPE"
option_layer_ooc_scotland: "Regne Unit històric: Escòcia"
+ option_layer_os_streetview: "UK: OS StreetView"
option_layer_streets_haiti: "Haití: noms de carrers"
option_layer_tip: Escollir el fons a mostrar
option_limitways: Avisar si hi ha molta càrrega de dades
tags_backtolist: Torna a la llista
tags_descriptions: Descripcions de '$1'
tags_findatag: Troba una etiqueta
+ tags_findtag: Cerca una etiqueta
tags_matching: Etiquetes populars que coincideixen amb '$1'
tags_typesearchterm: "Introdueixi una paraula per a buscar:"
tip_addrelation: Afegir a una relació
# Exported from translatewiki.net
# Export driver: syck
# Author: Ebbe
+# Author: Winbladh
da:
a_poi: $1 et POI
a_way: $1 en vej
action_addpoint: tilføjer et punkt til enden af en vej
action_cancelchanges: afbryder ændringer af
+ action_createparallel: skaber parallelle veje
action_createpoi: lave et POI (interessant punkt)
action_deletepoint: sletter et punkt
action_insertnode: tilføj et punkt på vejen
action_pointtags: sætter tags på et punkt
action_poitags: sætter tags på et POI (interessant punkt)
action_reverseway: vend retningen på en vej
+ action_revertway: returnere en vej
action_splitway: del en vej
action_waytags: sætter tags på en vej
+ advanced: Avanceret
+ advanced_close: Luk Changeset
+ advanced_maximise: Maksimer vinduet
+ advanced_minimise: Minimer vindue
+ advanced_parallel: Parallel vej
+ advanced_undelete: Genopret
+ advice_deletingpoi: Sletning af POI (Z for at fortryde)
+ advice_deletingway: Sletter vej (Z for at fortryde)
+ advice_revertingway: Vender tilbage til sidst gemte vej (Z for at fortryde)
+ advice_toolong: For lang for låse op - venligst opdel i kortere veje
+ advice_uploadempty: Intet at uploade
+ advice_uploadsuccess: Alle data uploadet succesfuldt
+ advice_waydragged: Way flyttet (Z for at fortryde)
cancel: Afbryd
+ closechangeset: Lukker Changeset
+ conflict_overwrite: Overskriv deres version
+ conflict_poichanged: Siden du begyndte at redigere, har en anden ændret punkt $ 1 $ 2.
+ conflict_relchanged: Siden du begyndte at redigere, har en anden ændret relation $1 $2.
+ conflict_visitway: Klik på 'Ok' for at vise vejen.
+ conflict_waychanged: Siden du begyndte at redigere, har en anden ændret vej $1 $2.
createrelation: Lav en ny relation
+ custom: "Custom:"
delete: Slet
deleting: sletter
+ editinglive: Live redigering
+ editingoffline: Redigering offline
emailauthor: \n\nVenligst send en e-mail (på engelsk) til richard\@systemeD.net med en fejlrapport, og forklar hvad du gjorde da det skete.
error_connectionfailed: Beklager - forbindelsen til OpenStreetMap-serveren fejlede, eventuelle nye ændringer er ikke blevet gemt. \n\nVil du prøve igen?
error_nopoi: Fandt ikke POI-et, så det er ikke muligt at fortryde. (Måske er den ikke på skærmen længere?)
error_nosharedpoint: Vejene $1 og $2 deler ikke noget punkt længere, så det er ikke muligt at fortryde delingen.
error_noway: Fandt ikke vejen $1 så det er ikke muligt at fortryde. (Måske er den ikke på skærmen længere?)
+ error_readfailed: Beklager - OpenStreetMap-serveren reagere ikke.\n\nVil du prøve igen?
existingrelation: Føj til en eksisterende relation
findrelation: Find en relation som indeholder
gpxpleasewait: Vent venligst mens GPX sporet behandles.
+ heading_introduction: Indledning
+ heading_surveying: Undersøge
help: Hjælp
hint_drawmode: klik for at tilføje punkt\ndobbeltklik eller enter\nfor at afslutte linie
hint_loading: henter veje
hint_overendpoint: over endepunkt\nklik for at forbinde\nshift+klik for at slå sammen til en
hint_overpoint: over punkt\nklik for at forbinde
hint_pointselected: punkt valgt\n(shift+klik punktet for at\nstarte en ny linie)
+ hint_saving: gemmer data
+ inspector: Inspektor
+ inspector_duplicate: Duplikat af
+ inspector_in_ways: I veje
+ inspector_locked: Låst
+ inspector_not_in_any_ways: Ikke på nogen veje (POI)
+ inspector_unsaved: Ikke gemt
+ inspector_uploading: (Uploading)
+ inspector_way_connects_to_principal: Forbinder til $1 $2 og $3 andre $4
+ inspector_way_nodes_closed: $1 noder (lukkede)
+ login_pwd: "Password:"
+ login_retry: Dit login blev ikke genkendt. Prøv venligst igen.
+ login_title: Kunne ikke logge ind
+ login_uid: "Brugernavn:"
+ mail: Post
+ newchangeset: "Prøv venligst igen: Potlatch vil starte et nyt changeset.."
+ "no": Nej
+ nobackground: Ingen baggrund
norelations: Ingen relationer i området på skærmen
+ offset_choose: Vælg offset (m)
+ offset_dual: Dobbelt vej (D2)
+ ok: Ok
+ openchangeset: Åbner Changeset
option_custompointers: Brug pen- og håndvisere
option_fadebackground: Fjern baggrund
+ option_layer_cycle_map: OSM - cykel kort
+ option_layer_maplint: OSM - Maplint (fejl)
+ option_layer_nearmap: "Australien: NearMap"
+ option_layer_ooc_25k: "UK historisk: 1:25 k"
+ option_layer_os_streetview: "UK: OS StreetView"
+ option_layer_streets_haiti: "Haiti: gadenavne"
+ option_layer_tip: Vælg baggrunden til visning
+ option_limitways: Advar ved loading af masser af data
+ option_microblog_id: "Microblog navn:"
+ option_microblog_pwd: "Microblog password:"
+ option_photo: "Foto KML:"
+ option_thinareas: Brug tyndere linjer for områder
option_thinlines: Brug tynde linier uanset skalering
+ option_tiger: Fremhæv uændret TIGER
+ option_warnings: Vis flydende advarsler
point: Punkt
+ preset_icon_airport: Lufthavn
+ preset_icon_bar: Bar
+ preset_icon_cafe: Café
+ preset_icon_cinema: Biograf
+ preset_icon_disaster: Haiti bygning
+ preset_icon_fast_food: Fast food
+ preset_icon_ferry_terminal: Færge
+ preset_icon_fire_station: Brandstation
+ preset_icon_hospital: Hospital
+ preset_icon_hotel: Hotel
+ preset_icon_museum: Museum
+ preset_icon_parking: Parkering
+ preset_icon_place_of_worship: Sted for tilbedelse
+ preset_icon_police: Politistation
+ preset_icon_post_box: Postkasse
+ preset_icon_recycling: Genbrug
+ preset_icon_school: Skole
+ preset_icon_station: Togstation
+ preset_icon_taxi: Taxaholdeplads
+ preset_icon_telephone: Telefon
+ preset_tip: Vælg fra menuen af preset tags, der beskriver $1
prompt_addtorelation: Tilføj $1 til en relation
+ prompt_changesetcomment: "Indtast en beskrivelse af dine ændringer:"
+ prompt_createparallel: Opret parallel vej
+ prompt_editlive: Edit live
+ prompt_helpavailable: Ny bruger? Kig nederst til venstre for at få hjælp.
+ prompt_launch: Start ekstern URL
+ prompt_manyways: Dette område er meget detaljerede, og vil tage lang tid at hente. Foretrækker du at zoome ind?
prompt_revertversion: "Ret tilbage til tidligere lagret version:"
- prompt_taggedpoints: Nogle af punktene på denne vej har tags. Vil du virkelig slette?
+ prompt_savechanges: Gem ændringer
+ prompt_taggedpoints: Nogle af punktene på denne vej har tags eller er i en relation. Vil du virkelig slette?
prompt_track: Overfør dine GPS-spor til (låste) veje for redigering.
prompt_welcome: Velkommen til OpenStreetMap!
+ retry: Prøv igen
+ revert: Fortryd
+ save: Gem
+ tags_backtolist: Tilbage til listen
+ tags_descriptions: Beskrivelser af '$ 1'
+ tags_findtag: Find tag
+ tags_matching: Populære tags matchende '$1'
tip_addrelation: Føj til en relation
tip_addtag: Tilføj et tag
tip_alert: Der opstod en fejl, klik for detaljer
tip_gps: Vis GPS spor (G)
tip_noundo: Intet at fortryde
tip_options: Sæt indstillinger (vælg kortbaggrund)
+ tip_photo: Load billeder
tip_presettype: Vælg hvilke type forhåndsinstillinger som er tilgænglige i menuen
tip_repeattag: Gentag tags fra senest valgte vej (R)
tip_revertversion: Vælg versionen der skal rettes tilbage til
tip_selectrelation: Føj til den valgte rute
tip_splitway: Del vej i valgt punkt (X)
+ tip_tidy: Nydeliggøre vejpunkter (T)
tip_undo: Fortryd $1 (Z)
+ uploading: Overfører ...
+ uploading_deleting_ways: Sletter veje
+ uploading_poi: Uploading POI $1
+ uploading_relation_name: Uploading relation $1, $2
+ uploading_way_name: Uploading vej$ 1, $ 2
+ warning: Advarsel!
way: Vej
+ "yes": Ja
# Author: CygnusOlor
# Author: Fnolz
# Author: Grille chompa
+# Author: LWChris
# Author: Markobr
# Author: Michi
# Author: Pill
action_createpoi: Einen Ort von Interesse (POI) erstellen
action_deletepoint: Punkt löschen
action_insertnode: Punkt auf Weg hinzufügen
- action_mergeways: Zwei Wege verschmelzen
+ action_mergeways: Zwei Wege zusammenlegen
action_movepoi: Ort von Interesse (POI) verschieben
action_movepoint: Punkt verschieben
action_moveway: einen Weg verschieben
retry: Retry
revert: Revert
save: Save
+ tags_findtag: Find tag
tags_findatag: Find a tag
tags_typesearchterm: "Type a word to look for:"
tags_matching: Popular tags matching '$1'
option_layer_ooc_7th: "Histórico de UK: 7th"
option_layer_ooc_npe: "Histórico de UK: NPE"
option_layer_ooc_scotland: "UK histórico: Escocia"
+ option_layer_os_streetview: "UK: OS StreetView"
option_layer_streets_haiti: "Haiti: nombres de calles"
option_layer_tip: Elija el fondo a mostrar
option_limitways: Lanza una advertencia al cargar gran cantidad de datos.
save: Guardar
tags_backtolist: Volver a la lista
tags_descriptions: Descripciones de '$1'
- tags_findatag: Encontrar una etiqueta
+ tags_findatag: Busca una etiqueta
+ tags_findtag: Busca una etiqueta
tags_matching: Etiquetas populares que coinciden con '$1'
tags_typesearchterm: "Introduzca una palabra para buscar:"
tip_addrelation: Añadir a una relación
option_layer_ooc_7th: Historique UK 7e
option_layer_ooc_npe: Historique UK NPE
option_layer_ooc_scotland: "Royaume-Uni historique : Ecosse"
+ option_layer_os_streetview: "RU : OS StreetView"
option_layer_streets_haiti: "Haïti: noms des rues"
option_layer_tip: Choisir l'arrière-plan à afficher
option_limitways: Avertir lors du chargement d'une grande quantité de données
prompt_microblog: Poster sur $1 ($2 restant)
prompt_revertversion: "Revenir à une version sauvegardée antérieure :"
prompt_savechanges: Sauvegarder les modifications
- prompt_taggedpoints: Certains points de ce chemin sont associés à des mots-clé ou dans des relations. Voulez-vous vraiment les supprimer ?
+ prompt_taggedpoints: Certains points de ce chemin sont associés à des balises ou dans des relations. Voulez-vous vraiment les supprimer ?
prompt_track: Conversion d'une trace GPS en chemin (verrouillé) pour l'édition
prompt_unlock: Cliquer pour déverrouiller
prompt_welcome: Bienvenue sur OpenStreetMap !
save: Sauvegarder
tags_backtolist: Retour à la liste
tags_descriptions: Descriptions de « $1 »
- tags_findatag: Rechercher un mot-clé
- tags_matching: Mots-clés populaires correspondant à « $1 »
+ tags_findatag: Rechercher une balise
+ tags_findtag: Rechercher balise
+ tags_matching: Balises populaires correspondant à « $1 »
tags_typesearchterm: "Tapez le mot à rechercher :"
tip_addrelation: Ajouter à une relation
tip_addtag: Ajouter une nouvelle balise
option_layer_ooc_7th: "Historial UK: 7º"
option_layer_ooc_npe: "Historial UK: NPE"
option_layer_ooc_scotland: "RU histórico: Escocia"
+ option_layer_os_streetview: "RU: OS StreetView"
option_layer_streets_haiti: "Haití: nomes de rúas"
option_layer_tip: Escolla o fondo a mostrar
option_limitways: Avisar ao cargar moitos datos
tags_backtolist: Voltar á lista
tags_descriptions: Descricións de "$1"
tags_findatag: Atopar unha etiqueta
+ tags_findtag: Atopar unha etiqueta
tags_matching: Etiquetas populares que coinciden con "$1"
tags_typesearchterm: "Escriba unha palabra a procurar:"
tip_addrelation: Engadir a unha relación
option_layer_ooc_7th: "Wulka Britaniska historisce: 7th"
option_layer_ooc_npe: "Wulka Britaniska historisce: NPE"
option_layer_ooc_scotland: "Zjednoćene kralestwo historisce: Šotiska"
+ option_layer_os_streetview: "Zjednoćene kralestwo: OS StreetView"
option_layer_streets_haiti: "Haiti: dróhowe mjena"
option_layer_tip: Pozadk wubrać
option_limitways: Warnować, hdyž so jara wjele datow začituja
tags_backtolist: Wróćo k lisćinje
tags_descriptions: Wopisanja wot '$1'
tags_findatag: Atribut namakać
+ tags_findtag: Atribut namakać
tags_matching: Popularne atributy za '$1'
tags_typesearchterm: "Zapodaj pytanski wuraz:"
tip_addrelation: Relaciji přidać
option_layer_ooc_7th: "UK történelmi: 7th"
option_layer_ooc_npe: "UK történelmi: NPE"
option_layer_ooc_scotland: "UK történelmi: Skócia"
+ option_layer_os_streetview: "UK: OS utcanézet"
option_layer_streets_haiti: "Haiti: utcanevek"
option_layer_tip: Válaszd ki a megjelenítendő hátteret
option_limitways: Figyelmeztetés sok adat betöltése előtt
tags_backtolist: Vissza a listához
tags_descriptions: "'$1' leírása"
tags_findatag: Címke keresése
+ tags_findtag: Címke keresése
tags_matching: "Népszerű címkék, amelyek illeszkednek a következőre: '$1'"
tags_typesearchterm: "Írj be egy szót a kereséshez:"
tip_addrelation: Hozzáadás kapcsolathoz
option_layer_ooc_7th: "RU historic: 7me"
option_layer_ooc_npe: "RU historic: NPE"
option_layer_ooc_scotland: "RU historic: Scotia"
+ option_layer_os_streetview: "Regno Unite: OS StreetView"
option_layer_streets_haiti: "Haiti: nomines de stratas"
option_layer_tip: Selige le fundo a monstrar
option_limitways: Advertir si multe datos debe esser cargate
prompt_microblog: Publicar in $1 (il remane $2)
prompt_revertversion: "Reverter a un version previemente salveguardate:"
prompt_savechanges: Salveguardar modificationes
- prompt_taggedpoints: Alcunes del punctos in iste via es etiquettate. Realmente deler?
+ prompt_taggedpoints: Alcunes del punctos in iste via ha etiquettas o relationes. Realmente deler?
prompt_track: Converter tracia GPS in vias
prompt_unlock: Clicca pro disblocar
prompt_welcome: Benvenite a OpenStreetMap!
tags_backtolist: Retornar al lista
tags_descriptions: Descriptiones de '$1'
tags_findatag: Cercar un etiquetta
+ tags_findtag: Cercar etiquetta
tags_matching: Etiquettas popular correspondente a '$1'
tags_typesearchterm: "Entra un parola a cercar:"
tip_addrelation: Adder a un relation
login_pwd: "Password:"
login_retry: Il tuo login non è stato riconosciuto. Riprova
login_title: Impossibile fare il login
- login_uid: Nome utente
+ login_uid: "Nome utente:"
mail: Posta
more: Ancora
newchangeset: "Si prega di riprovare: Potlatch aprirà un nuovo gruppo di modifiche."
uploading_way_name: Caricamento percorso $1, $2
warning: Attenzione!
way: Percorso
- "yes": Si
+ "yes": Sì
option_layer_ooc_7th: "Историски британски: 7-ми"
option_layer_ooc_npe: "Историски британски: NPE"
option_layer_ooc_scotland: "Историски британски: Шкотска"
+ option_layer_os_streetview: "Британија: OS StreetView"
option_layer_streets_haiti: "Хаити: имиња на улици"
option_layer_tip: Изберете позадина
option_limitways: Предупреди ме кога се вчитува голем број на податоци
tags_backtolist: Назад кон листата
tags_descriptions: Описи на „$1“
tags_findatag: Најди ознака
+ tags_findtag: Најди ознака
tags_matching: Популарни ознаки соодветни на „$1“
tags_typesearchterm: "Внесете збор за пребарување:"
tip_addrelation: Додај во релација
tags_backtolist: Terug naar de lijst
tags_descriptions: Beschrijvingen van "$1"
tags_findatag: Label zoeken
+ tags_findtag: Label zoeken
tags_matching: Populaire labels voor "$1"
tags_typesearchterm: "Zoeken naar:"
tip_addrelation: Voeg toe aan een relatie
preset_icon_bus_stop: Busstopp
preset_icon_cafe: Kafé
preset_icon_cinema: Kino
+ preset_icon_convenience: Nærbutikk
preset_icon_disaster: Bygning i Haiti
preset_icon_fast_food: Fastfood
preset_icon_ferry_terminal: Ferge
preset_icon_school: Skole
preset_icon_station: Jernbanestasjon
preset_icon_supermarket: Supermarked
+ preset_icon_taxi: Drosjeholdeplass
preset_icon_telephone: Telefon
preset_icon_theatre: Teater
preset_tip: Velg fra en meny med forhåndsdefinerte merkelapper som beskriver $1
tags_backtolist: Tilbake til liste
tags_descriptions: Beskrivelser av '$1'
tags_findatag: Finn et merke
+ tags_findtag: Finn merkelapp
tags_matching: Populære merker som passer '$1̈́'
tags_typesearchterm: "Skriv inn et ord å lete etter:"
tip_addrelation: Legg til i en relasjon
option_layer_ooc_7th: "UK histórico: 7th"
option_layer_ooc_npe: "UK histórico: NPE"
option_layer_ooc_scotland: "UK histórico: Escócia"
+ option_layer_os_streetview: "UK: OS StreetView"
option_layer_osmarender: OSM - Osmarender
option_layer_streets_haiti: "Haiti: nomes de ruas"
option_layer_tip: Escolha o fundo a mostrar
tags_backtolist: Voltar à lista
tags_descriptions: Descrições de '$1'
tags_findatag: Encontrar uma etiqueta
+ tags_findtag: Etiquetas
tags_matching: Etiquetas populares que coincidem com '$1'
tags_typesearchterm: "Digite uma palavra para buscar:"
tip_addrelation: Adicionar a uma relação
option_layer_ooc_7th: "UK historic: 7th"
option_layer_ooc_npe: "UK historic: NPE"
option_layer_ooc_scotland: "UK historic: Scotland"
+ option_layer_os_streetview: "UK: OS StreetView"
option_layer_osmarender: OSM - Osmarender
option_layer_streets_haiti: "Гаити: названия улиц"
option_layer_tip: Выберите фон
tags_backtolist: Вернуться к списку
tags_descriptions: Описание «$1»
tags_findatag: Найти тег
+ tags_findtag: Найти тег
tags_matching: Популярные теги, соответствующие «$1»
tags_typesearchterm: "Введите слово для поиска:"
tip_addrelation: Добавить отношение
option_layer_ooc_7th: "Anh lịch sử: lần in 7"
option_layer_ooc_npe: "Anh lịch sử: NPE"
option_layer_ooc_scotland: "Anh lịch sử: Scotland"
+ option_layer_os_streetview: "Anh: OS StreetView"
option_layer_osmarender: OSM – Osmarender
option_layer_streets_haiti: "Haiti: tên đường sá"
option_layer_tip: Chọn nền để hiển thị
prompt_microblog: Đăng lên $1 (còn $2 chữ)
prompt_revertversion: "Lùi lại phiên bản cũ hơn:"
prompt_savechanges: Lưu các thay đổi
- prompt_taggedpoints: Một số điểm trên lối này đã được gắn thẻ. Bạn có chắc muốn xóa nó?
+ prompt_taggedpoints: Một số điểm trên lối này đã được gắn thẻ hoặc thuộc về quan hệ. Bạn có chắc muốn xóa nó?
prompt_track: Chuyển đổi tuyến đường GPS thành các lối (khóa) để sửa đổi.
prompt_unlock: Nhấn chuột để mở khóa
prompt_welcome: Hoan nghênh bạn đã đến OpenStreetMap!
tags_backtolist: Quay lại danh sách
tags_descriptions: Miêu tả “$1”
tags_findatag: Tìm kiếm thẻ
+ tags_findtag: Tìm kiếm thẻ
tags_matching: Các thẻ phổ biến trùng hợp với “$1”
tags_typesearchterm: "Nhập từ để tìm kiếm:"
tip_addrelation: Xếp vào quan hệ
--- /dev/null
+Makefile
+quad_tile.o
+quad_tile_so.so
--- /dev/null
+stats
+user
});
var mapnik = new OpenLayers.Layer.OSM.Mapnik(i18n("javascripts.map.base.mapnik"), {
+ keyid: "mapnik",
displayOutsideMaxExtent: true,
wrapDateLine: true
});
map.addLayer(mapnik);
var osmarender = new OpenLayers.Layer.OSM.Osmarender(i18n("javascripts.map.base.osmarender"), {
+ keyid: "osmarender",
displayOutsideMaxExtent: true,
wrapDateLine: true
});
map.addLayer(osmarender);
var cyclemap = new OpenLayers.Layer.OSM.CycleMap(i18n("javascripts.map.base.cycle_map"), {
+ keyid: "cyclemap",
displayOutsideMaxExtent: true,
wrapDateLine: true
});
+++ /dev/null
-/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
- * See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
- * text of the license. */
-////
-/// This blob sucks in all the files in uncompressed form for ease of use
-///
-
-OpenLayers = new Object();
-
-OpenLayers._scriptName = (
- typeof(_OPENLAYERS_SFL_) == "undefined" ? "lib/OpenLayers.js"
- : "OpenLayers.js" );
-
-OpenLayers._getScriptLocation = function () {
- var scriptLocation = "";
- var SCRIPT_NAME = OpenLayers._scriptName;
-
- var scripts = document.getElementsByTagName('script');
- for (var i = 0; i < scripts.length; i++) {
- var src = scripts[i].getAttribute('src');
- if (src) {
- var index = src.lastIndexOf(SCRIPT_NAME);
- // is it found, at the end of the URL?
- if ((index > -1) && (index + SCRIPT_NAME.length == src.length)) {
- scriptLocation = src.slice(0, -SCRIPT_NAME.length);
- break;
- }
- }
- }
- return scriptLocation;
-}
-
-/*
- `_OPENLAYERS_SFL_` is a flag indicating this file is being included
- in a Single File Library build of the OpenLayers Library.
-
- When we are *not* part of a SFL build we dynamically include the
- OpenLayers library code.
-
- When we *are* part of a SFL build we do not dynamically include the
- OpenLayers library code as it will be appended at the end of this file.
-*/
-if (typeof(_OPENLAYERS_SFL_) == "undefined") {
- /*
- The original code appeared to use a try/catch block
- to avoid polluting the global namespace,
- we now use a anonymous function to achieve the same result.
- */
- (function() {
- var jsfiles=new Array(
- "Prototype.js",
- "Rico/Corner.js",
- "Rico/Color.js",
- "OpenLayers/Util.js",
- "OpenLayers/Ajax.js",
- "OpenLayers/Events.js",
- "OpenLayers/Map.js",
- "OpenLayers/Layer.js",
- "OpenLayers/Icon.js",
- "OpenLayers/Marker.js",
- "OpenLayers/Popup.js",
- "OpenLayers/Tile.js",
- "OpenLayers/Feature.js",
- "OpenLayers/Feature/WFS.js",
- "OpenLayers/Tile/Image.js",
- "OpenLayers/Tile/WFS.js",
-// "OpenLayers/Layer/Google.js",
-// "OpenLayers/Layer/VirtualEarth.js",
-// "OpenLayers/Layer/Yahoo.js",
- "OpenLayers/Layer/Grid.js",
- "OpenLayers/Layer/KaMap.js",
- "OpenLayers/Layer/Markers.js",
- "OpenLayers/Layer/Text.js",
- "OpenLayers/Layer/WMS.js",
- "OpenLayers/Layer/WFS.js",
- "OpenLayers/Layer/WMS/Untiled.js",
- "OpenLayers/Popup/Anchored.js",
- "OpenLayers/Popup/AnchoredBubble.js",
- "OpenLayers/Control.js",
- "OpenLayers/Control/MouseDefaults.js",
- "OpenLayers/Control/MouseToolbar.js",
- "OpenLayers/Control/KeyboardDefaults.js",
- "OpenLayers/Control/PanZoom.js",
- "OpenLayers/Control/PanZoomBar.js",
- "OpenLayers/Control/LayerSwitcher.js"
- ); // etc.
-
- var allScriptTags = "";
- var host = OpenLayers._getScriptLocation() + "lib/";
-
- // check to see if prototype.js was already loaded
- // if so, skip the first dynamic include
- //
- var start=1;
- try { x = Prototype; }
- catch (e) { start=0; }
-
- for (var i = start; i < jsfiles.length; i++) {
- var currentScriptTag = "<script src='" + host + jsfiles[i] + "'></script>";
- allScriptTags += currentScriptTag;
- }
- document.write(allScriptTags);
- })();
-}
+++ /dev/null
-/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
- * See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
- * text of the license. */
-\r
-OpenLayers.ProxyHost = "/proxy/?url=";\r
-//OpenLayers.ProxyHost = "examples/proxy.cgi?url=";\r
-\r
-/**\r
-* Ajax reader for OpenLayers\r
-*\r
-*@uri url to do remote XML http get\r
-*@param 'get' format params (x=y&a=b...)\r
-*@who object to handle callbacks for this request\r
-*@complete the function to be called on success \r
-*@failure the function to be called on failure\r
-*\r
-* example usage from a caller:\r
-*\r
-* caps: function(request) {\r
-* -blah- \r
-* },\r
-*\r
-* OpenLayers.loadURL(url,params,this,caps);\r
-*\r
-* Notice the above example does not provide an error handler; a default empty\r
-* handler is provided which merely logs the error if a failure handler is not \r
-* supplied\r
-*\r
-*/\r
-\r
-\r
-/** \r
-* @param {} request\r
-*/\r
-OpenLayers.nullHandler = function(request) {\r
- alert("Unhandled request return " + request.statusText);\r
-};\r
-\r
-/** Background load a document\r
-*\r
-* @param {String} uri URI of source doc\r
-* @param {String} params Params on get (doesnt seem to work)\r
-* @param {Object} caller object which gets callbacks\r
-* @param {Function} onComplete callback for success\r
-* @param {Function} onFailure callback for failure\r
-*\r
-* Both callbacks optional (though silly)\r
-*/\r
-OpenLayers.loadURL = function(uri, params, caller,\r
- onComplete, onFailure) {\r
-\r
- if (OpenLayers.ProxyHost && uri.startsWith("http")) {\r
- uri = OpenLayers.ProxyHost + escape(uri);\r
-\r
- if (!params) {\r
- params="";\r
- }\r
- params += "&cachehack=" + new Date().getTime();\r
- }\r
-\r
- var success = (onComplete) ? onComplete.bind(caller)\r
- : OpenLayers.nullHandler;\r
-\r
- var failure = (onFailure) ? onFailure.bind(caller)\r
- : OpenLayers.nullHandler;\r
-\r
- // from prototype.js\r
- new Ajax.Request(uri, \r
- { method: 'get', \r
- parameters: params,\r
- onComplete: success, \r
- onFailure: failure\r
- }\r
- );\r
-};\r
-\r
-/** Parse XML into a doc structure\r
-* @param {String} text\r
-*\r
-* @returns Parsed Ajax Response ??\r
-* @type ?\r
-*/\r
-OpenLayers.parseXMLString = function(text) {\r
-\r
- //MS sucks, if the server is bad it dies\r
- var index = text.indexOf('<');\r
- if (index > 0) {\r
- text = text.substring(index);\r
- }\r
-\r
- var ajaxResponse = Try.these(\r
- function() {\r
- var xmldom = new ActiveXObject('Microsoft.XMLDOM');\r
- xmldom.loadXML(text);\r
- return xmldom;\r
- },\r
- function() {\r
- return new DOMParser().parseFromString(text, 'text/xml');\r
- },\r
- function() {\r
- var req = new XMLHttpRequest();\r
- req.open("GET", "data:" + "text/xml" +\r
- ";charset=utf-8," + encodeURIComponent(text), false);\r
- if (req.overrideMimeType) {\r
- req.overrideMimeType("text/xml");\r
- }\r
- req.send(null);\r
- return req.responseXML;\r
- }\r
- );\r
-\r
- return ajaxResponse;\r
-};
+++ /dev/null
-/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
- * See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
- * text of the license. */
-/**
-* @class
-*/
-OpenLayers.Control = Class.create();
-OpenLayers.Control.prototype = {
-
- /** this gets set in the addControl() function in OpenLayers.Map
- * @type OpenLayers.Map */
- map: null,
-
- /** @type DOMElement */
- div: null,
-
- /** @type OpenLayers.Pixel */
- position: null,
-
- /**
- * @constructor
- */
- initialize: function (options) {
- Object.extend(this, options);
- },
-
- /**
- * @param {OpenLayers.Pixel} px
- *
- * @returns A reference to the DIV DOMElement containing the control
- * @type DOMElement
- */
- draw: function (px) {
- if (this.div == null) {
- this.div = OpenLayers.Util.createDiv();
- }
- if (px != null) {
- this.position = px.copyOf();
- }
- this.moveTo(this.position);
- return this.div;
- },
-
- /**
- * @param {OpenLayers.Pixel} px
- */
- moveTo: function (px) {
- if ((px != null) && (this.div != null)) {
- this.div.style.left = px.x + "px";
- this.div.style.top = px.x + "px";
- }
- },
-
- /**
- */
- destroy: function () {
- // eliminate circular references
- this.map = null;
- },
-
- /** @final @type String */
- CLASS_NAME: "OpenLayers.Control"
-};
+++ /dev/null
-/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
- * See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
- * text of the license. */
-// @require: OpenLayers/Control.js
-
-/**
- * @class
- */
-OpenLayers.Control.KeyboardDefaults = Class.create();
-OpenLayers.Control.KeyboardDefaults.prototype =
- Object.extend( new OpenLayers.Control(), {
-
- /** @type int */
- slideFactor: 50,
-
- /**
- * @constructor
- */
- initialize: function() {
- OpenLayers.Control.prototype.initialize.apply(this, arguments);
- },
-
- /**
- *
- */
- draw: function() {
- Event.observe(document,
- 'keypress',
- this.defaultKeyDown.bind(this));
- },
-
- /**
- * @param {Event} evt
- */
- defaultKeyDown: function (evt) {
-
- var slide = this.map.getResolution() * this.slideFactor;
- var center = this.map.getCenter();
-
- var newCenter = center.copyOf();
-
- switch(evt.keyCode) {
- case Event.KEY_LEFT:
- newCenter = newCenter.add( -slide, 0);
- break;
- case Event.KEY_RIGHT:
- newCenter = newCenter.add( slide, 0);
- break;
- case Event.KEY_UP:
- newCenter = newCenter.add( 0, slide);
- break;
- case Event.KEY_DOWN:
- newCenter = newCenter.add( 0, -slide);
- break;
- }
-
- if (!newCenter.equals(center)) {
- this.map.setCenter(newCenter);
- Event.stop(evt);
- }
- },
-
- /** @final @type String */
- CLASS_NAME: "OpenLayers.Control.KeyboardDefaults"
-});
+++ /dev/null
-/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
- * See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
- * text of the license. */
-// @require: OpenLayers/Control.js
-/**
-* @class
-*/
-OpenLayers.Control.LayerSwitcher = Class.create();
-
-/** color used in the UI to show a layer is active/displayed
-*
-* @final
-* @type String
-*/
-OpenLayers.Control.LayerSwitcher.ACTIVE_COLOR = "darkblue";
-
-/** color used in the UI to show a layer is deactivated/hidden
-*
-* @final
-* @type String
-*/
-OpenLayers.Control.LayerSwitcher.NONACTIVE_COLOR = "lightblue";
-
-
-OpenLayers.Control.LayerSwitcher.prototype =
- Object.extend( new OpenLayers.Control(), {
-
- /** @type String */
- activeColor: "",
-
- /** @type String */
- nonActiveColor: "",
-
- /** @type String */
- mode: "checkbox",
-
- /**
- * @constructor
- */
- initialize: function(options) {
- this.activeColor = OpenLayers.Control.LayerSwitcher.ACTIVE_COLOR;
- this.nonActiveColor = OpenLayers.Control.LayerSwitcher.NONACTIVE_COLOR;
- this.backdrops = [];
- OpenLayers.Control.prototype.initialize.apply(this, arguments);
- },
-
- /**
- * @returns A reference to the DIV DOMElement containing the switcher tabs
- * @type DOMElement
- */
- draw: function() {
- // initialize our internal div
- OpenLayers.Control.prototype.draw.apply(this);
-
- this.div.style.position = "absolute";
- this.div.style.top = "10px";
- this.div.style.right = "0px";
- this.div.style.left = "";
- this.div.style.fontFamily = "sans-serif";
- this.div.style.color = "white";
- this.div.style.fontWeight = "bold";
- this.div.style.marginTop = "3px";
- this.div.style.marginLeft = "3px";
- this.div.style.marginBottom = "3px";
- this.div.style.fontSize="smaller";
- this.div.style.width = "10em";
-
- this.map.events.register("addlayer", this, this.redraw);
- this.map.events.register("removelayer", this, this.redraw);
- return this.redraw();
- },
-
- /**
- * @returns A reference to the DIV DOMElement containing the switcher tabs
- * @type DOMElement
- */
- redraw: function() {
-
- //clear out previous incarnation of LayerSwitcher tabs
- this.div.innerHTML = "";
- var visible = false;
- for( var i = 0; i < this.map.layers.length; i++) {
- if (visible && this.mode == "radio") {
- this.map.layers[i].setVisibility(false);
- } else {
- visible = this.map.layers[i].getVisibility();
- }
- this.addTab(this.map.layers[i]);
- }
-
- return this.div;
- },
-
- /**
- * @param {event} evt
- */
- singleClick: function(evt) {
- var div = Event.element(evt);
-
- // See comment about OL #57 fix below.
- // If the click occurred on the corner spans we need
- // to make sure we act on the actual label tab instead.
- div = div.labelElement || div;
-
- var layer = div.layer;
- if (this.mode == "radio") {
- for(var i=0; i < this.backdrops.length; i++) {
- this.setTabActivation(this.backdrops[i], false);
- this.backdrops[i].layer.setVisibility(false);
- }
- this.setTabActivation(div, true);
- layer.setVisibility(true);
- } else {
- var visible = layer.getVisibility();
-
- this.setTabActivation(div, !visible);
- layer.setVisibility(!visible);
- }
- Event.stop(evt);
- },
-
- /**
- * @private
- *
- * @param {event} evt
- */
- ignoreEvent: function(evt) {
- Event.stop(evt);
- return false;
- },
-
- /**
- * @private
- *
- * @param {OpenLayers.Layer} layer
- */
- addTab: function(layer) {
-
- // Outer DIV - for Rico Corners
- //
- var backdropLabelOuter = document.createElement('div');
- backdropLabelOuter.id = "LayerSwitcher_" + layer.name + "_Tab";
- backdropLabelOuter.style.marginTop = "4px";
- backdropLabelOuter.style.marginBottom = "4px";
-
- this._setEventHandlers(backdropLabelOuter);
-
- // Inner Label - for Rico Corners
- //
- var backdropLabel = document.createElement('p');
- backdropLabel.innerHTML = layer.name;
- backdropLabel.style.marginTop = "0px";
- backdropLabel.style.marginBottom = "0px";
- backdropLabel.style.paddingLeft = "10px";
- backdropLabel.style.paddingRight = "10px";
-
- // add reference to layer onto the div for use in event handlers
- backdropLabel.layer = layer;
-
- // set event handlers
- this._setEventHandlers(backdropLabel);
-
- // add label to div
- backdropLabelOuter.appendChild(backdropLabel);
-
- this.backdrops.append(backdropLabel);
-
- // add div to main LayerSwitcher Div
- this.div.appendChild(backdropLabelOuter);
-
- Rico.Corner.round(backdropLabelOuter, {corners: "tl bl",
- bgColor: "transparent",
- color: "white",
- blend: false});
-
- // extend the event handlers to operate on the
- // rounded corners as well. (Fixes OL #57.)
- var spanElements=backdropLabel.parentNode.getElementsByTagName("span");
-
- for (var currIdx = 0; currIdx < spanElements.length; currIdx++) {
- this._setEventHandlers(spanElements[currIdx], backdropLabel);
- }
-
- this.setTabActivation(backdropLabel, layer.getVisibility());
- },
-
- /*
- @private
-
- @param {DOMElement} div
- @param {Boolean} activate
- */
- _setEventHandlers : function(element, labelDiv) {
-
- // We only want to respond to a mousedown event.
- element.onclick = this.singleClick.bindAsEventListener(this);
- element.ondblclick = this.singleClick.bindAsEventListener(this);
- element.onmouseup = this.ignoreEvent.bindAsEventListener(this);
- element.onmousedown = this.ignoreEvent.bindAsEventListener(this);
-
- // If we are operating on a corner span we need to store a
- // reference to the actual tab. (See comment about OL #57 fix above.)
- if (labelDiv) {
- element.labelElement = labelDiv;
- }
- },
-
- /**
- * @private
- *
- * @param {DOMElement} div
- * @param {Boolean} activate
- */
- setTabActivation:function(div, activate) {
- var color = (activate) ? this.activeColor : this.nonActiveColor;
- Rico.Corner.changeColor(div, color);
- },
-
-
-
- /** @final @type String */
- CLASS_NAME: "OpenLayers.Control.LayerSwitcher"
-});
-
+++ /dev/null
-/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
- * See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
- * text of the license. */
-// @require: OpenLayers/Control.js
-OpenLayers.Control.MouseDefaults = Class.create();
-OpenLayers.Control.MouseDefaults.prototype =
- Object.extend( new OpenLayers.Control(), {
-
- performedDrag: false,
-
- initialize: function() {
- OpenLayers.Control.prototype.initialize.apply(this, arguments);
- },
-
- draw: function() {
- this.map.events.register( "click", this, this.defaultClick );
- this.map.events.register( "dblclick", this, this.defaultDblClick );
- this.map.events.register( "mousedown", this, this.defaultMouseDown );
- this.map.events.register( "mouseup", this, this.defaultMouseUp );
- this.map.events.register( "mousemove", this, this.defaultMouseMove );
- this.map.events.register( "mouseout", this, this.defaultMouseOut );
- },
-
- defaultClick: function (evt) {
- if (!Event.isLeftClick(evt)) return;
- var notAfterDrag = !this.performedDrag;
- this.performedDrag = false;
- return notAfterDrag;
- },
-
- /**
- * @param {Event} evt
- */
- defaultDblClick: function (evt) {
- var newCenter = this.map.getLonLatFromViewPortPx( evt.xy );
- this.map.setCenter(newCenter, this.map.zoom + 1);
- },
-
- /**
- * @param {Event} evt
- */
- defaultMouseDown: function (evt) {
- if (!Event.isLeftClick(evt)) return;
- this.mouseDragStart = evt.xy.copyOf();
- this.performedDrag = false;
- if (evt.shiftKey) {
- this.map.div.style.cursor = "crosshair";
- this.zoomBox = OpenLayers.Util.createDiv('zoomBox',
- this.mouseDragStart,
- null,
- null,
- "absolute",
- "2px solid red");
- this.zoomBox.style.backgroundColor = "white";
- this.zoomBox.style.filter = "alpha(opacity=50)"; // IE
- this.zoomBox.style.opacity = "0.50";
- this.zoomBox.style.zIndex = this.map.Z_INDEX_BASE["Popup"] - 1;
- this.map.viewPortDiv.appendChild(this.zoomBox);
- }
- document.onselectstart=function() { return false; }
- Event.stop(evt);
- },
-
- /**
- * @param {Event} evt
- */
- defaultMouseMove: function (evt) {
- if (this.mouseDragStart != null) {
- if (this.zoomBox) {
- var deltaX = Math.abs(this.mouseDragStart.x - evt.xy.x);
- var deltaY = Math.abs(this.mouseDragStart.y - evt.xy.y);
- this.zoomBox.style.width = deltaX+"px";
- this.zoomBox.style.height = deltaY+"px";
- if (evt.xy.x < this.mouseDragStart.x) {
- this.zoomBox.style.left = evt.xy.x+"px";
- }
- if (evt.xy.y < this.mouseDragStart.y) {
- this.zoomBox.style.top = evt.xy.y+"px";
- }
- } else {
- var deltaX = this.mouseDragStart.x - evt.xy.x;
- var deltaY = this.mouseDragStart.y - evt.xy.y;
- var size = this.map.getSize();
- var newXY = new OpenLayers.Pixel(size.w / 2 + deltaX,
- size.h / 2 + deltaY);
- var newCenter = this.map.getLonLatFromViewPortPx( newXY );
- this.map.setCenter(newCenter, null, true);
- this.mouseDragStart = evt.xy.copyOf();
- this.map.div.style.cursor = "move";
- }
- this.performedDrag = true;
- }
- },
-
- /**
- * @param {Event} evt
- */
- defaultMouseUp: function (evt) {
- if (!Event.isLeftClick(evt)) return;
- if (this.zoomBox) {
- var start = this.map.getLonLatFromViewPortPx( this.mouseDragStart );
- var end = this.map.getLonLatFromViewPortPx( evt.xy );
- var top = Math.max(start.lat, end.lat);
- var bottom = Math.min(start.lat, end.lat);
- var left = Math.min(start.lon, end.lon);
- var right = Math.max(start.lon, end.lon);
- var bounds = new OpenLayers.Bounds(left, bottom, right, top);
- var zoom = this.map.getZoomForExtent(bounds);
- this.map.setCenter(new OpenLayers.LonLat(
- (start.lon + end.lon) / 2,
- (start.lat + end.lat) / 2
- ), zoom);
- this.map.viewPortDiv.removeChild(document.getElementById("zoomBox"));
- this.zoomBox = null;
- } else {
- this.map.setCenter(this.map.center);
- }
- document.onselectstart=null;
- this.mouseDragStart = null;
- this.map.div.style.cursor = "default";
- },
-
- defaultMouseOut: function (evt) {
- if (this.mouseDragStart != null
- && OpenLayers.Util.mouseLeft(evt, this.map.div)) {
- this.defaultMouseUp(evt);
- }
- }
-});
-
+++ /dev/null
-/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
- * See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
- * text of the license. */
-// @require: OpenLayers/Control.js
-OpenLayers.Control.MouseToolbar = Class.create();
-OpenLayers.Control.MouseToolbar.X = 6;
-OpenLayers.Control.MouseToolbar.Y = 300;
-OpenLayers.Control.MouseToolbar.prototype =
- Object.extend( new OpenLayers.Control(), {
-
- mode: null,
-
- buttons: null,
-
- direction: "vertical",
-
- initialize: function(position, direction) {
- OpenLayers.Control.prototype.initialize.apply(this, arguments);
- this.position = new OpenLayers.Pixel(OpenLayers.Control.MouseToolbar.X,
- OpenLayers.Control.MouseToolbar.Y);
- if (position) {
- this.position = position;
- }
- if (direction) {
- this.direction = direction;
- }
- this.measureDivs = [];
- },
-
- draw: function() {
- OpenLayers.Control.prototype.draw.apply(this, arguments);
- this.buttons = new Object();
- this.map.events.register( "dblclick", this, this.defaultDblClick );
- this.map.events.register( "mousedown", this, this.defaultMouseDown );
- this.map.events.register( "mouseup", this, this.defaultMouseUp );
- this.map.events.register( "mousemove", this, this.defaultMouseMove );
- this.map.events.register( "mouseout", this, this.defaultMouseOut );
- var sz = new OpenLayers.Size(28,28);
- var centered = this.position;
- this._addButton("zoombox", "drag-rectangle-off.png", "drag-rectangle-on.png", centered, sz, "Shift->Drag to zoom to area");
- centered = centered.add((this.direction == "vertical" ? 0 : sz.w), (this.direction == "vertical" ? sz.h : 0));
- this._addButton("pan", "panning-hand-off.png", "panning-hand-on.png", centered, sz, "Drag the map to pan.");
- centered = centered.add((this.direction == "vertical" ? 0 : sz.w), (this.direction == "vertical" ? sz.h : 0));
- this._addButton("measure", "measuring-stick-off.png", "measuring-stick-on.png", centered, sz, "Hold alt when clicking to show distance between selected points");
- this.switchModeTo("pan");
- this.map.events.register("zoomend", this, function() { this.switchModeTo("pan"); });
- return this.div;
-
- },
-
- _addButton:function(id, img, activeImg, xy, sz, title) {
- var imgLocation = OpenLayers.Util.getImagesLocation() + img;
- var activeImgLocation = OpenLayers.Util.getImagesLocation() + activeImg;
- // var btn = new ol.AlphaImage("_"+id, imgLocation, xy, sz);
- var btn = OpenLayers.Util.createAlphaImageDiv(
- "OpenLayers_Control_MouseToolbar_" + id,
- xy, sz, imgLocation, "absolute");
-
- //we want to add the outer div
- this.div.appendChild(btn);
- btn.imgLocation = imgLocation;
- btn.activeImgLocation = activeImgLocation;
-
- btn.events = new OpenLayers.Events(this, btn);
- btn.events.register("mousedown", this, this.buttonClick);
- btn.events.register("mouseup", this, Event.stop);
- btn.action = id;
- btn.title = title;
- btn.alt = title;
- btn.map = this.map;
-
- //we want to remember/reference the outer div
- this.buttons[id] = btn;
- return btn;
- },
-
- buttonClick: function(evt) {
- if (!Event.isLeftClick(evt)) return;
- this.switchModeTo(evt.div.action);
- Event.stop(evt);
- },
-
- /**
- * @param {Event} evt
- */
- defaultDblClick: function (evt) {
- this.switchModeTo("pan");
- var newCenter = this.map.getLonLatFromViewPortPx( evt.xy );
- this.map.setCenter(newCenter, this.map.zoom + 2);
- },
-
- /**
- * @param {Event} evt
- */
- defaultMouseDown: function (evt) {
- if (!Event.isLeftClick(evt)) return;
- this.mouseDragStart = evt.xy.copyOf();
- if (evt.shiftKey && this.mode !="zoombox") {
- this.switchModeTo("zoombox");
- } else if (evt.altKey && this.mode !="measure") {
- this.switchModeTo("measure");
- } else if (!this.mode) {
- this.switchModeTo("pan");
- }
-
- switch (this.mode) {
- case "zoombox":
- this.map.div.style.cursor = "crosshair";
- this.zoomBox = OpenLayers.Util.createDiv('zoomBox',
- this.mouseDragStart,
- null,
- null,
- "absolute",
- "2px solid red");
- this.zoomBox.style.backgroundColor = "white";
- this.zoomBox.style.filter = "alpha(opacity=50)"; // IE
- this.zoomBox.style.opacity = "0.50";
- this.zoomBox.style.zIndex = this.map.Z_INDEX_BASE["Popup"] - 1;
- this.map.viewPortDiv.appendChild(this.zoomBox);
- break;
- case "measure":
- var distance = "";
- if (this.measureStart) {
- measureEnd = this.map.getLonLatFromViewPortPx(this.mouseDragStart);
- distance = OpenLayers.Util.distVincenty(this.measureStart, measureEnd);
- distance = Math.round(distance * 100) / 100;
- distance = distance + "km";
- this.measureStartBox = this.measureBox;
- }
- this.measureStart = this.map.getLonLatFromViewPortPx(this.mouseDragStart);;
- this.measureBox = OpenLayers.Util.createDiv(null,
- this.mouseDragStart.add(
- -2-parseInt(this.map.layerContainerDiv.style.left),
- -2-parseInt(this.map.layerContainerDiv.style.top)),
- null,
- null,
- "absolute");
- this.measureBox.style.width="4px";
- this.measureBox.style.height="4px";
- this.measureBox.style.backgroundColor="red";
- this.measureBox.style.zIndex = this.map.Z_INDEX_BASE["Popup"] - 1;
- this.map.layerContainerDiv.appendChild(this.measureBox);
- if (distance) {
- this.measureBoxDistance = OpenLayers.Util.createDiv(null,
- this.mouseDragStart.add(
- -2-parseInt(this.map.layerContainerDiv.style.left),
- 2-parseInt(this.map.layerContainerDiv.style.top)),
- null,
- null,
- "absolute");
-
- this.measureBoxDistance.innerHTML = distance;
- this.measureBoxDistance.style.zIndex = this.map.Z_INDEX_BASE["Popup"] - 1;
- this.map.layerContainerDiv.appendChild(this.measureBoxDistance);
- this.measureDivs.append(this.measureBoxDistance);
- }
- this.measureBox.style.zIndex = this.map.Z_INDEX_BASE["Popup"] - 1;
- this.map.layerContainerDiv.appendChild(this.measureBox);
- this.measureDivs.append(this.measureBox);
- break;
- default:
- this.map.div.style.cursor = "move";
- break;
- }
- document.onselectstart = function() { return false; }
- Event.stop(evt);
- },
-
- switchModeTo: function(mode) {
- if (mode != this.mode) {
- if (this.mode) {
- OpenLayers.Util.modifyAlphaImageDiv(this.buttons[this.mode], null, null, null, this.buttons[this.mode].imgLocation);
- }
- if (this.mode == "measure" && mode != "measure") {
- for(var i = 0; i < this.measureDivs.length; i++) {
- if (this.measureDivs[i]) {
- this.map.layerContainerDiv.removeChild(this.measureDivs[i]);
- }
- }
- this.measureDivs = [];
- this.measureStart = null;
- }
- this.mode = mode;
- OpenLayers.Util.modifyAlphaImageDiv(this.buttons[mode], null, null, null, this.buttons[mode].activeImgLocation);
- }
- },
-
- leaveMode: function() {
- this.switchModeTo("pan");
- },
-
- /**
- * @param {Event} evt
- */
- defaultMouseMove: function (evt) {
- if (this.mouseDragStart != null) {
- switch (this.mode) {
- case "zoombox":
- var deltaX = Math.abs(this.mouseDragStart.x - evt.xy.x);
- var deltaY = Math.abs(this.mouseDragStart.y - evt.xy.y);
- this.zoomBox.style.width = deltaX+"px";
- this.zoomBox.style.height = deltaY+"px";
- if (evt.xy.x < this.mouseDragStart.x) {
- this.zoomBox.style.left = evt.xy.x+"px";
- }
- if (evt.xy.y < this.mouseDragStart.y) {
- this.zoomBox.style.top = evt.xy.y+"px";
- }
- break;
- default:
- var deltaX = this.mouseDragStart.x - evt.xy.x;
- var deltaY = this.mouseDragStart.y - evt.xy.y;
- var size = this.map.getSize();
- var newXY = new OpenLayers.Pixel(size.w / 2 + deltaX,
- size.h / 2 + deltaY);
- var newCenter = this.map.getLonLatFromViewPortPx( newXY );
- this.map.setCenter(newCenter, null, true);
- this.mouseDragStart = evt.xy.copyOf();
- }
- }
- },
-
- /**
- * @param {Event} evt
- */
- defaultMouseUp: function (evt) {
- if (!Event.isLeftClick(evt)) return;
- switch (this.mode) {
- case "zoombox":
- var start = this.map.getLonLatFromViewPortPx( this.mouseDragStart );
- var end = this.map.getLonLatFromViewPortPx( evt.xy );
- var top = Math.max(start.lat, end.lat);
- var bottom = Math.min(start.lat, end.lat);
- var left = Math.min(start.lon, end.lon);
- var right = Math.max(start.lon, end.lon);
- var bounds = new OpenLayers.Bounds(left, bottom, right, top);
- var zoom = this.map.getZoomForExtent(bounds);
- this.map.setCenter(new OpenLayers.LonLat(
- (start.lon + end.lon) / 2,
- (start.lat + end.lat) / 2
- ), zoom);
- this.map.viewPortDiv.removeChild(document.getElementById("zoomBox"));
- this.zoomBox = null;
- this.leaveMode();
- break;
- case "pan":
- this.map.setCenter(this.map.center);
-
- }
- document.onselectstart = null;
- this.mouseDragStart = null;
- this.map.div.style.cursor = "default";
- },
-
- defaultMouseOut: function (evt) {
- if (this.mouseDragStart != null
- && OpenLayers.Util.mouseLeft(evt, this.map.div)) {
- this.defaultMouseUp(evt);
- }
- }
-});
-
+++ /dev/null
-/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
- * See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
- * text of the license. */
-// @require: OpenLayers/Control.js
-
-/**
- * @class
- *
- * default zoom/pan controls
- */
-OpenLayers.Control.PanZoom = Class.create();
-OpenLayers.Control.PanZoom.X = 4;
-OpenLayers.Control.PanZoom.Y = 4;
-OpenLayers.Control.PanZoom.prototype =
- Object.extend( new OpenLayers.Control(), {
-
- /** @type int */
- slideFactor: 50,
-
- /** @type Array of Button Divs */
- buttons: null,
-
- /** @type OpenLayers.Pixel */
- position: null,
-
- /**
- * @constructor
- */
- initialize: function() {
- OpenLayers.Control.prototype.initialize.apply(this, arguments);
- this.position = new OpenLayers.Pixel(OpenLayers.Control.PanZoom.X,
- OpenLayers.Control.PanZoom.Y);
- },
-
- /**
- * @param {OpenLayers.Pixel} px
- *
- * @returns A reference to the container div for the PanZoom control
- * @type DOMElement
- */
- draw: function(px) {
- // initialize our internal div
- OpenLayers.Control.prototype.draw.apply(this, arguments);
- px = this.position;
-
- // place the controls
- this.buttons = new Array();
-
- var sz = new OpenLayers.Size(18,18);
- var centered = new OpenLayers.Pixel(px.x+sz.w/2, px.y);
-
- this._addButton("panup", "north-mini.png", centered, sz);
- px.y = centered.y+sz.h;
- this._addButton("panleft", "west-mini.png", px, sz);
- this._addButton("panright", "east-mini.png", px.add(sz.w, 0), sz);
- this._addButton("pandown", "south-mini.png",
- centered.add(0, sz.h*2), sz);
- this._addButton("zoomin", "zoom-plus-mini.png",
- centered.add(0, sz.h*3+5), sz);
- this._addButton("zoomworld", "zoom-world-mini.png",
- centered.add(0, sz.h*4+5), sz);
- this._addButton("zoomout", "zoom-minus-mini.png",
- centered.add(0, sz.h*5+5), sz);
- return this.div;
- },
-
- /**
- * @param {String} id
- * @param {String} img
- * @param {OpenLayers.Pixel} xy
- * @param {OpenLayers.Size} sz
- *
- * @returns A Div (an alphaImageDiv, to be precise) that contains the
- * image of the button, and has all the proper event handlers
- * set.
- * @type DOMElement
- */
- _addButton:function(id, img, xy, sz) {
- var imgLocation = OpenLayers.Util.getImagesLocation() + img;
- // var btn = new ol.AlphaImage("_"+id, imgLocation, xy, sz);
- var btn = OpenLayers.Util.createAlphaImageDiv(
- "OpenLayers_Control_PanZoom_" + id,
- xy, sz, imgLocation, "absolute");
-
- //we want to add the outer div
- this.div.appendChild(btn);
-
- btn.onmousedown = this.buttonDown.bindAsEventListener(btn);
- btn.ondblclick = this.doubleClick.bindAsEventListener(btn);
- btn.onclick = this.doubleClick.bindAsEventListener(btn);
- btn.action = id;
- btn.map = this.map;
- btn.slideFactor = this.slideFactor;
-
- //we want to remember/reference the outer div
- this.buttons.push(btn);
- return btn;
- },
-
- /**
- * @param {event} evt
- *
- * @type Boolean
- */
- doubleClick: function (evt) {
- Event.stop(evt);
- return false;
- },
-
- /**
- * @param {event} evt
- */
- buttonDown: function (evt) {
- if (!Event.isLeftClick(evt)) return;
-
- var slide = this.map.getResolution() * this.slideFactor;
- var center = this.map.getCenter();
-
- var newCenter = center.copyOf();
-
- switch (this.action) {
- case "panup":
- newCenter = newCenter.add( 0, slide);
- break;
- case "pandown":
- newCenter = newCenter.add( 0, -slide);
- break;
- case "panleft":
- newCenter = newCenter.add( -slide, 0);
- break;
- case "panright":
- newCenter = newCenter.add( slide, 0);
- break;
- case "zoomin":
- this.map.zoomIn();
- break;
- case "zoomout":
- this.map.zoomOut();
- break;
- case "zoomworld":
- this.map.zoomToFullExtent();
- break;
- }
-
- if (!newCenter.equals(center)) {
- this.map.setCenter(newCenter);
- }
-
- Event.stop(evt);
- },
-
- /**
- *
- */
- destroy: function() {
- OpenLayers.Control.prototype.destroy.apply(this, arguments);
- for(i=0; i<this.buttons.length; i++) {
- this.buttons[i].map = null;
- }
- },
-
- /** @final @type String */
- CLASS_NAME: "OpenLayers.Control.PanZoom"
-});
+++ /dev/null
-/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
- * See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
- * text of the license. */
-// @require: OpenLayers/Control/PanZoom.js
-
-//
-// default zoom/pan controls
-//
-OpenLayers.Control.PanZoomBar = Class.create();
-OpenLayers.Control.PanZoomBar.X = 4;
-OpenLayers.Control.PanZoomBar.Y = 4;
-OpenLayers.Control.PanZoomBar.prototype =
- Object.extend( new OpenLayers.Control.PanZoom(), {
- /** @type Array(...) */
- buttons: null,
-
- /** @type int */
- zoomStopWidth: 18,
-
- /** @type int */
- zoomStopHeight: 11,
-
- initialize: function() {
- OpenLayers.Control.PanZoom.prototype.initialize.apply(this, arguments);
- this.position = new OpenLayers.Pixel(OpenLayers.Control.PanZoomBar.X,
- OpenLayers.Control.PanZoomBar.Y);
- },
-
- /**
- * @param {OpenLayers.Pixel} px
- */
- draw: function(px) {
- // initialize our internal div
- OpenLayers.Control.prototype.draw.apply(this, arguments);
- px = this.position;
-
- // place the controls
- this.buttons = new Array();
-
- var sz = new OpenLayers.Size(18,18);
- var centered = new OpenLayers.Pixel(px.x+sz.w/2, px.y);
-
- this._addButton("panup", "north-mini.png", centered, sz);
- px.y = centered.y+sz.h;
- this._addButton("panleft", "west-mini.png", px, sz);
- this._addButton("panright", "east-mini.png", px.add(sz.w, 0), sz);
- this._addButton("pandown", "south-mini.png", centered.add(0, sz.h*2), sz);
- this._addButton("zoomin", "zoom-plus-mini.png", centered.add(0, sz.h*3+5), sz);
- centered = this._addZoomBar(centered.add(0, sz.h*4 + 5));
- this._addButton("zoomout", "zoom-minus-mini.png", centered, sz);
- return this.div;
- },
-
- /**
- * @param {OpenLayers.Pixel} location where zoombar drawing is to start.
- */
- _addZoomBar:function(centered) {
- var imgLocation = OpenLayers.Util.getImagesLocation();
-
- var id = "OpenLayers_Control_PanZoomBar_Slider" + this.map.id;
- var slider = OpenLayers.Util.createAlphaImageDiv(id,
- centered.add(-1,
- (this.map.getZoomLevels())*this.zoomStopHeight),
- new OpenLayers.Size(20,9),
- imgLocation+"slider.png",
- "absolute");
- this.slider = slider;
-
- this.sliderEvents = new OpenLayers.Events(this, slider);
- this.sliderEvents.register("mousedown", this, this.zoomBarDown);
- this.sliderEvents.register("mousemove", this, this.zoomBarDrag);
- this.sliderEvents.register("mouseup", this, this.zoomBarUp);
- this.sliderEvents.register("dblclick", this, this.doubleClick);
- this.sliderEvents.register("click", this, this.doubleClick);
-
- sz = new OpenLayers.Size();
- sz.h = this.zoomStopHeight*(this.map.getZoomLevels()+1);
- sz.w = this.zoomStopWidth;
- var div = null
-
- if (OpenLayers.Util.alphaHack()) {
- var id = "OpenLayers_Control_PanZoomBar" + this.map.id;
- div = OpenLayers.Util.createAlphaImageDiv(id, centered,
- new OpenLayers.Size(sz.w,
- this.zoomStopHeight),
- imgLocation + "zoombar.png",
- "absolute", null, "crop");
- div.style.height = sz.h;
- } else {
- div = OpenLayers.Util.createDiv(
- 'OpenLayers_Control_PanZoomBar_Zoombar' + this.map.id,
- centered,
- sz,
- imgLocation+"zoombar.png");
- }
-
- this.zoombarDiv = div;
-
- this.divEvents = new OpenLayers.Events(this, div);
- this.divEvents.register("mousedown", this, this.divClick);
- this.divEvents.register("mousemove", this, this.passEventToSlider);
- this.divEvents.register("dblclick", this, this.doubleClick);
- this.divEvents.register("click", this, this.doubleClick);
-
- this.div.appendChild(div);
-
- this.startTop = parseInt(div.style.top);
- this.div.appendChild(slider);
-
- this.map.events.register("zoomend", this, this.moveZoomBar);
-
- centered = centered.add(0,
- this.zoomStopHeight*(this.map.getZoomLevels()+1));
- return centered;
- },
- /*
- * @param evt
- * This function is used to pass events that happen on the div, or the map,
- * through to the slider, which then does its moving thing.
- */
- passEventToSlider:function(evt) {
- this.sliderEvents.handleBrowserEvent(evt);
- },
-
- /*
- * divClick: Picks up on clicks directly on the zoombar div
- * and sets the zoom level appropriately.
- */
- divClick: function (evt) {
- if (!Event.isLeftClick(evt)) return;
- var y = evt.xy.y;
- var top = Position.page(evt.object)[1];
- var levels = Math.floor((y - top)/this.zoomStopHeight);
- this.map.zoomTo(this.map.getZoomLevels() - levels);
- Event.stop(evt);
- },
-
- /*
- * @param evt
- * event listener for clicks on the slider
- */
- zoomBarDown:function(evt) {
- if (!Event.isLeftClick(evt)) return;
- this.map.events.register("mousemove", this, this.passEventToSlider);
- this.map.events.register("mouseup", this, this.passEventToSlider);
- this.mouseDragStart = evt.xy.copyOf();
- this.zoomStart = evt.xy.copyOf();
- this.div.style.cursor = "move";
- Event.stop(evt);
- },
-
- /*
- * @param evt
- * This is what happens when a click has occurred, and the client is dragging.
- * Here we must ensure that the slider doesn't go beyond the bottom/top of the
- * zoombar div, as well as moving the slider to its new visual location
- */
- zoomBarDrag:function(evt) {
- if (this.mouseDragStart != null) {
- var deltaY = this.mouseDragStart.y - evt.xy.y
- var offsets = Position.page(this.zoombarDiv);
- if ((evt.clientY - offsets[1]) > 0 &&
- (evt.clientY - offsets[1]) < parseInt(this.zoombarDiv.style.height) - 2) {
- var newTop = parseInt(this.slider.style.top) - deltaY;
- this.slider.style.top = newTop+"px";
- }
- this.mouseDragStart = evt.xy.copyOf();
- }
- Event.stop(evt);
- },
-
- /*
- * @param evt
- * Perform cleanup when a mouseup event is received -- discover new zoom level
- * and switch to it.
- */
- zoomBarUp:function(evt) {
- if (!Event.isLeftClick(evt)) return;
- if (this.zoomStart) {
- this.div.style.cursor="default";
- this.map.events.remove("mousemove");
- this.map.events.remove("mouseup");
- var deltaY = this.zoomStart.y - evt.xy.y
- this.map.zoomTo(this.map.zoom + Math.round(deltaY/this.zoomStopHeight));
- this.moveZoomBar();
- this.mouseDragStart = null;
- Event.stop(evt);
- }
- },
-
- /*
- * Change the location of the slider to match the current zoom level.
- */
- moveZoomBar:function() {
- var newTop =
- (this.map.getZoomLevels() - this.map.getZoom()) * this.zoomStopHeight
- + this.startTop + 1;
- this.slider.style.top = newTop + "px";
- },
-
- CLASS_NAME: "OpenLayers.Control.PanZoomBar"
-});
+++ /dev/null
-/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
- * See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
- * text of the license. */
-OpenLayers.Events = Class.create();
-
-OpenLayers.Events.prototype = {
- // Array: supported events
- BROWSER_EVENTS: [
- "mouseover", "mouseout",
- "mousedown", "mouseup", "mousemove",
- "click", "dblclick",
- "resize", "focus", "blur"
- ],
-
- // hash of Array(Function): events listener functions
- listeners: null,
-
- // Object: the code object issuing application events
- object: null,
-
- // DOMElement: the DOM element receiving browser events
- div: null,
-
- // Array: list of support application events
- eventTypes: null,
-
- /**
- * @param {OpenLayers.Map} map
- * @param {DOMElement} div
- */
- initialize: function (object, div, eventTypes) {
- this.listeners = {};
- this.object = object;
- this.div = div;
- this.eventTypes = eventTypes;
- if (eventTypes) {
- for (var i = 0; i < this.eventTypes.length; i++) {
- // create a listener list for every custom application event
- this.listeners[ this.eventTypes[i] ] = [];
- }
- }
- for (var i = 0; i < this.BROWSER_EVENTS.length; i++) {
- var eventType = this.BROWSER_EVENTS[i];
-
- // every browser event has a corresponding application event
- // (whether it's listened for or not).
- this.listeners[ eventType ] = [];
-
- Event.observe(div, eventType,
- this.handleBrowserEvent.bindAsEventListener(this));
- }
- // disable dragstart in IE so that mousedown/move/up works normally
- Event.observe(div, "dragstart", Event.stop);
- },
-
- /**
- * @param {str} type
- * @param {Object} obj
- * @param {Function} func
- */
- register: function (type, obj, func) {
- if (func == null) {
- obj = this.object;
- func = obj;
- }
- var listeners = this.listeners[type];
- listeners.push( {obj: obj, func: func} );
- },
-
- unregister: function (type, obj, func) {
- var listeners = this.listeners[type];
- for (var i = 0; i < listeners.length; i++) {
- if (listeners[i].obj == obj && listeners[i].type == type) {
- listeners.splice(i, 1);
- break;
- }
- }
- },
-
- remove: function(type) {
- this.listeners[type].pop();
- },
-
- /**
- * @param {event} evt
- */
- handleBrowserEvent: function (evt) {
- evt.xy = this.getMousePosition(evt);
- this.triggerEvent(evt.type, evt)
- },
-
- /**
- * @param {event} evt
- *
- * @return {OpenLayers.Pixel}
- */
- getMousePosition: function (evt) {
- if (!this.div.offsets) {
- this.div.offsets = Position.page(this.div);
- }
- return new OpenLayers.Pixel(
- evt.clientX - this.div.offsets[0],
- evt.clientY - this.div.offsets[1]);
- },
-
- /**
- * @param {str} type
- * @param {event} evt
- */
- triggerEvent: function (type, evt) {
- if (evt == null) {
- evt = {};
- }
- evt.object = this.object;
- evt.div = this.div;
-
- var listeners = this.listeners[type];
- for (var i = 0; i < listeners.length; i++) {
- var callback = listeners[i];
- var continueChain = callback.func.call(callback.obj, evt);
- if (continueChain != null && !continueChain) break;
- }
- }
-};
+++ /dev/null
-/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
- * See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
- * text of the license. */
-/**
- * @class
- */
-OpenLayers.Feature = Class.create();
-OpenLayers.Feature.prototype= {
-
- /** @type OpenLayers.Events */
- events:null,
-
- /** @type OpenLayers.Layer */
- layer: null,
-
- /** @type String */
- id: null,
-
- /** @type OpenLayers.LonLat */
- lonlat:null,
-
- /** @type Object */
- data:null,
-
- /** @type OpenLayers.Marker */
- marker: null,
-
- /** @type OpenLayers.Popup */
- popup: null,
-
- /**
- * @constructor
- *
- * @param {OpenLayers.Layer} layer
- * @param {String} id
- * @param {OpenLayers.LonLat} lonlat
- * @param {Object} data
- */
- initialize: function(layer, lonlat, data, id) {
- this.layer = layer;
- this.lonlat = lonlat;
- this.data = (data != null) ? data : new Object();
- this.id = (id ? id : 'f' + Math.random());
- },
-
- /**
- *
- */
- destroy: function() {
-
- //remove the popup from the map
- if ((this.layer != null) && (this.layer.map != null)) {
- if (this.popup != null) {
- this.layer.map.removePopup(this.popup);
- }
- }
-
- this.events = null;
- this.layer = null;
- this.id = null;
- this.lonlat = null;
- this.data = null;
- if (this.marker != null) {
- this.marker.destroy();
- this.marker = null;
- }
- if (this.popup != null) {
- this.popup.destroy();
- this.popup = null;
- }
- },
-
-
- /**
- * @returns A Marker Object created from the 'lonlat' and 'icon' properties
- * set in this.data. If no 'lonlat' is set, returns null. If no
- * 'icon' is set, OpenLayers.Marker() will load the default image
- * @type OpenLayers.Marker
- */
- createMarker: function() {
-
- var marker = null;
-
- if (this.lonlat != null) {
- this.marker = new OpenLayers.Marker(this.lonlat, this.data.icon);
- }
- return this.marker;
- },
-
- /**
- *
- */
- createPopup: function() {
-
- if (this.lonlat != null) {
-
- var id = this.id + "_popup";
- var anchor = (this.marker) ? this.marker.icon : null;
-
- this.popup = new OpenLayers.Popup.AnchoredBubble(id,
- this.lonlat,
- this.data.popupSize,
- this.data.popupContentHTML,
- anchor);
- }
- return this.popup;
- },
-
- CLASS_NAME: "OpenLayers.Feature"
-};
+++ /dev/null
-/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
- * See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
- * text of the license. */
-/**\r
- * @class\r
- */\r
-OpenLayers.Feature.WFS = Class.create();\r
-OpenLayers.Feature.WFS.prototype = \r
- Object.extend( new OpenLayers.Feature(), {\r
- \r
- /** \r
- * @constructor\r
- * \r
- * @param {OpenLayers.Layer} layer\r
- * @param {XMLNode} xmlNode\r
- */\r
- initialize: function(layer, xmlNode) {\r
- var newArguments = arguments;\r
- if (arguments.length > 0) {\r
- var data = this.processXMLNode(xmlNode);\r
- newArguments = new Array(layer, data.lonlat, data, data.id)\r
- }\r
- OpenLayers.Feature.prototype.initialize.apply(this, newArguments);\r
- \r
- if (arguments.length > 0) {\r
- this.createMarker();\r
- this.layer.addMarker(this.marker);\r
- }\r
- },\r
- \r
- destroy: function() {\r
- if (this.marker != null) {\r
- this.layer.removeMarker(this.marker); \r
- }\r
- OpenLayers.Feature.prototype.destroy.apply(this, arguments);\r
- },\r
-\r
- /**\r
- * @param {XMLNode} xmlNode\r
- * \r
- * @returns Data Object with 'id', 'lonlat', and private properties set\r
- * @type Object\r
- */\r
- processXMLNode: function(xmlNode) {\r
- //this should be overridden by subclasses\r
- // must return an Object with 'id' and 'lonlat' values set\r
- var point = xmlNode.getElementsByTagName("Point");
- var text = point[0].textContent;
- var floats = text.split(",");
-
- return {lonlat: new OpenLayers.LonLat(parseFloat(floats[0]),
- parseFloat(floats[1])),
- id: null};
-
- },\r
- \r
- /** @final @type String */\r
- CLASS_NAME: "OpenLayers.Feature.WFS"\r
-});\r
- \r
- \r
- \r
- \r
-\r
+++ /dev/null
-/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
- * See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
- * text of the license. */
-/**
-* @class
-*/
-OpenLayers.Icon = Class.create();
-OpenLayers.Icon.prototype = {
-
- /** image url
- * @type String */
- url: null,
-
- /** @type OpenLayers.Size */
- size:null,
-
- /** distance in pixels to offset the image when being rendered
- * @type OpenLayers.Pixel */
- offset: null,
-
- /** Function to calculate the offset (based on the size)
- * @type OpenLayers.Pixel */
- calculateOffset: null,
-
- /** @type DOMElement */
- imageDiv: null,
-
- /** @type OpenLayers.Pixel */
- px: null,
-
- /**
- * @constructor
- *
- * @param {String} url
- * @param {OpenLayers.Size} size
- * @param {Function} calculateOffset
- */
- initialize: function(url, size, offset, calculateOffset) {
- this.url = url;
- this.size = (size) ? size : new OpenLayers.Size(20,20);
- this.offset = (offset) ? offset : new OpenLayers.Pixel(0,0);
- this.calculateOffset = calculateOffset;
-
- this.imageDiv = OpenLayers.Util.createAlphaImageDiv();
- },
-
- destroy: function() {
- this.imageDiv = null;
- },
-
- /**
- * @returns A fresh copy of the icon.
- * @type OpenLayers.Icon
- */
- clone: function() {
- return new OpenLayers.Icon(this.size, this.url, this.offset);
- },
-
- /**
- * @param {OpenLayers.Size} size
- */
- setSize: function(size) {
- if (size != null) {
- this.size = size;
- }
- this.draw();
- },
-
- /**
- * @param {OpenLayers.Pixel} px
- *
- * @return A new DOM Image of this icon set at the location passed-in
- * @type DOMElement
- */
- draw: function(px) {
- OpenLayers.Util.modifyAlphaImageDiv(this.imageDiv,
- null,
- null,
- this.size,
- this.url,
- "absolute");
- this.moveTo(px);
- return this.imageDiv;
- },
-
- /**
- * @param {OpenLayers.Pixel} px
- */
- moveTo: function (px) {
- //if no px passed in, use stored location
- if (px != null) {
- this.px = px;
- }
-
- if ((this.px != null) && (this.imageDiv != null)) {
- if (this.calculateOffset) {
- this.offset = this.calculateOffset(this.size);
- }
- var offsetPx = this.px.offset(this.offset);
- OpenLayers.Util.modifyAlphaImageDiv(this.imageDiv, null, offsetPx);
- }
- },
-
- /** @final @type String */
- CLASS_NAME: "OpenLayers.Icon"
-};
\ No newline at end of file
+++ /dev/null
-/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
- * See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
- * text of the license. */
-/**
- * @class
- */
-OpenLayers.Layer = Class.create();
-OpenLayers.Layer.prototype = {
-
- /** @type String */
- name: null,
-
- /** @type DOMElement */
- div: null,
-
- /** This variable is set in map.addLayer, not within the layer itself
- * @type OpenLayers.Map */
- map: null,
-
- /**
- * @constructor
- *
- * @param {String} name
- */
- initialize: function(name) {
- if (arguments.length > 0) {
- this.name = name;
- if (this.div == null) {
- this.div = OpenLayers.Util.createDiv();
- this.div.style.width = "100%";
- this.div.style.height = "100%";
- }
- }
- },
-
- /**
- * Destroy is a destructor: this is to alleviate cyclic references which
- * the Javascript garbage cleaner can not take care of on its own.
- */
- destroy: function() {
- if (this.map != null) {
- this.map.removeLayer(this);
- }
- this.map = null;
- },
-
- /**
- * @params {OpenLayers.Bounds} bound
- * @params {Boolean} zoomChanged tells when zoom has changed, as layers have to do some init work in that case.
- */
- moveTo: function (bound, zoomChanged) {
- // not implemented here
- return;
- },
-
- /**
- * @param {OpenLayers.Map} map
- */
- setMap: function(map) {
- this.map = map;
- },
-
- /**
- * @returns Whether or not the layer is a base layer. This should be
- * determined individually by all subclasses.
- * @type Boolean
- */
- isBaseLayer: function() {
- //this function should be implemented by all subclasses.
- },
-
- /**
- * @returns Whether or not the layer is visible
- * @type Boolean
- */
- getVisibility: function() {
- return (this.div.style.display != "none");
- },
-
- /**
- * @param {bool} visible
- */
- setVisibility: function(visible) {
- this.div.style.display = (visible) ? "block" : "none";
- if ((visible) && (this.map != null)) {
- this.moveTo(this.map.getExtent());
- }
- },
-
- /** @final @type String */
- CLASS_NAME: "OpenLayers.Layer"
-};
+++ /dev/null
-/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
- * See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
- * text of the license. */
-// @require: OpenLayers/Layer.js
-
-// load Google map control script
-// this key was generated for: http://openlayers.python-hosting.com/testing/euzuro/
-document.write("<script src='http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAmQ3udCHPQVB_9T_edFZ7YRRRlP-tOiFgaSzksg_0w1dphL9c5BTfdJMKT91b0UJGibNcWEM0Q5-O1w'></script>");
-
-/**
- * @class
- */
-OpenLayers.Layer.Google = Class.create();
-OpenLayers.Layer.Google.prototype = Object.extend( new OpenLayers.Layer(), {
-
- /** @type Boolean */
- viewPortLayer: true,
-
- /** @type GMap2 gmap stores the Google Map element */
- gmap:null,
-
- /** @type Boolean */
- dragging:false,
-
- /**
- * @constructor
- *
- * @param {String} name
- */
- initialize: function(name) {
- OpenLayers.Layer.prototype.initialize.apply(this, [name]);
- },
-
- /**
- * @param {OpenLayers.Map} map
- */
- setMap:function(map) {
- OpenLayers.Layer.prototype.setMap.apply(this, arguments);
-
- // once our layer has been added to the map, we can create the vemap
- this.map.events.register("addlayer", this, this.loadGMap);
- },
-
- /** Google layer is always a base class.
- * @type Boolean
- */
- isBaseLayer: function() {
- return true;
- },
-
- /**
- * @param {OpenLayers.Bounds} bounds
- * @param {int} zoomChanged
- */
- moveTo:function(bounds,zoomChanged) {
-
- if ((this.gmap != null) && (!this.dragging)) {
-
- var olCenter = this.map.getCenter();
- var gCenter = this.getGMapCenter();
-
- var olZoom = this.map.getZoom();
- var gZoom = this.gmap.getZoom();
-
- if ((!olCenter.equals(gCenter)) || ((olZoom +1) != gZoom)) {
- this.gmap.setCenter(new GLatLng(olCenter.lat, olCenter.lon),
- olZoom + 1);
- }
- }
- },
-
- /**
- *
- */
- loadGMap:function() {
- // create div and set to same size as map
- var gDiv = OpenLayers.Util.createDiv(this.name);
- var sz = this.map.getSize();
- gDiv.style.width = sz.w;
- gDiv.style.height = sz.h;
- this.div.appendChild(gDiv);
-
- // create GMap, hide nav controls
- this.gmap = new GMap2(this.div);
- this.moveTo();
-
- // catch pans and zooms from GMap
- GEvent.addListener(this.gmap,
- "moveend",
- this.catchPanZoom.bindAsEventListener(this));
-
-
- // attach to the drag start and end and we´ll set a flag so that
- // we dont get recursivity. this is because the events fall through
- // the gmaps div and into the main layer div
- GEvent.addListener(this.gmap,
- "dragstart",
- this.dragStart.bindAsEventListener(this));
-
- GEvent.addListener(this.gmap,
- "dragend",
- this.dragEnd.bindAsEventListener(this));
-
- },
-
- /**
- * @private
- */
- dragStart: function() {
- this.dragging = true;
- },
-
- /**
- * @private
- */
- dragEnd: function() {
- this.dragging = false;
- },
-
- /**
- * @private
- *
- * @param {event} e
- */
- catchPanZoom: function(e) {
- var olCenter = this.getGMapCenter();
- var gZoom = this.gmap.getZoom();
-
- this.map.setCenter(olCenter, gZoom - 1);
-
- },
-
- /**
- * @private
- *
- * @returns An OpenLayers.LonLat with the center of the gmap, or null if
- * the GMap has not been centered yet
- * @type OpenLayers.LonLat
- */
- getGMapCenter:function() {
- var olCenter = null;
- var gCenter = this.gmap.getCenter();
- if (gCenter != null) {
- olCenter = new OpenLayers.LonLat(gCenter.lng(), gCenter.lat());
- }
- return olCenter;
- },
-
-
- /** @final @type String */
- CLASS_NAME: "OpenLayers.Layer.Google"
-});
+++ /dev/null
-/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
- * See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
- * text of the license. */
-// @require: OpenLayers/Layer.js
-// @require: OpenLayers/Util.js
-OpenLayers.Layer.Grid = Class.create();
-OpenLayers.Layer.Grid.TILE_WIDTH = 256;
-OpenLayers.Layer.Grid.TILE_HEIGHT = 256;
-OpenLayers.Layer.Grid.prototype = Object.extend( new OpenLayers.Layer(), {
-
- // str: url
- url: null,
-
- // hash: params
- params: null,
-
- // tileSize: OpenLayers.Size
- tileSize: null,
-
- // grid: Array(Array())
- // this is an array of rows, each row is an array of tiles
- grid: null,
-
- /**
- * @param {str} name
- * @param {str} url
- * @param {hash} params
- */
- initialize: function(name, url, params) {
- var newArguments = arguments;
- if (arguments.length > 0) {
- newArguments = [name];
- }
- OpenLayers.Layer.prototype.initialize.apply(this, newArguments);
- this.url = url;
- this.params = params;
- this.tileSize = new OpenLayers.Size(OpenLayers.Layer.Grid.TILE_WIDTH,
- OpenLayers.Layer.Grid.TILE_HEIGHT);
- },
-
- /**
- *
- */
- destroy: function() {
- this.params = null;
- this.clearGrid();
- this.grid = null;
- OpenLayers.Layer.prototype.destroy.apply(this, arguments);
- },
-
- setTileSize: function (size) {
- this.tileSize = size.copyOf();
- },
-
- /**
- * moveTo
- * moveTo is a function called whenever the map is moved. All the moving
- * of actual 'tiles' is done by the map, but moveTo's role is to accept
- * a bounds and make sure the data that that bounds requires is pre-loaded.
- * @param {OpenLayers.Bounds}
- */
- moveTo:function(bounds,zoomChanged) {
- if (!this.getVisibility()) {
- if (zoomChanged) {
- this.grid = null;
- }
- return;
- }
- if (!this.grid || zoomChanged) {
- this._initTiles();
- } else {
- var i = 0;
- while (this.getGridBounds().bottom > bounds.bottom) {
- this.insertRow(false);
- }
- while (this.getGridBounds().left > bounds.left) {
- this.insertColumn(true);
- }
- while (this.getGridBounds().top < bounds.top) {
- this.insertRow(true);
- }
- while (this.getGridBounds().right < bounds.right) {
- this.insertColumn(false);
- }
- }
- },
- getGridBounds:function() {
- var topLeftTile = this.grid[0][0];
- var bottomRightTile = this.grid[this.grid.length-1][this.grid[0].length-1];
- return new OpenLayers.Bounds(topLeftTile.bounds.left,
- bottomRightTile.bounds.bottom,
- bottomRightTile.bounds.right,
- topLeftTile.bounds.top);
- },
-
- /**
- */
- _initTiles:function() {
-
- //first of all, clear out the main div
- this.div.innerHTML = "";
-
- //now clear out the old grid and start a new one
- this.clearGrid();
- this.grid = new Array();
-
- var viewSize = this.map.getSize();
- var bounds = this.map.getExtent();
- var extent = this.map.getFullExtent();
- var resolution = this.map.getResolution();
- var tilelon = resolution*this.tileSize.w;
- var tilelat = resolution*this.tileSize.h;
-
- var offsetlon = bounds.left - extent.left;
- var tilecol = Math.floor(offsetlon/tilelon);
- var tilecolremain = offsetlon/tilelon - tilecol;
- var tileoffsetx = -tilecolremain * this.tileSize.w;
- var tileoffsetlon = extent.left + tilecol * tilelon;
-
- var offsetlat = bounds.top - (extent.bottom + tilelat);
- var tilerow = Math.ceil(offsetlat/tilelat);
- var tilerowremain = tilerow - offsetlat/tilelat;
- var tileoffsety = -tilerowremain * this.tileSize.h;
- var tileoffsetlat = extent.bottom + tilerow * tilelat;
-
- tileoffsetx = Math.round(tileoffsetx); // heaven help us
- tileoffsety = Math.round(tileoffsety);
-
- this.origin = new OpenLayers.Pixel(tileoffsetx,tileoffsety);
-
- var startX = tileoffsetx;
- var startLon = tileoffsetlon;
-
- do {
- var row = new Array();
- this.grid.append(row);
- tileoffsetlon = startLon;
- tileoffsetx = startX;
- do {
- var tileBounds = new OpenLayers.Bounds(tileoffsetlon,
- tileoffsetlat,
- tileoffsetlon+tilelon,
- tileoffsetlat+tilelat);
-
- var tile = this.addTile(tileBounds,
- new OpenLayers.Pixel(tileoffsetx - parseInt(this.map.layerContainerDiv.style.left),
- tileoffsety - parseInt(this.map.layerContainerDiv.style.top))
- );
- tile.draw((this.params.TRANSPARENT == 'true'));
- row.append(tile);
-
- tileoffsetlon += tilelon;
- tileoffsetx += this.tileSize.w;
- } while (tileoffsetlon < bounds.right)
-
- tileoffsetlat -= tilelat;
- tileoffsety += this.tileSize.h;
- } while(tileoffsetlat > bounds.bottom - tilelat)
-
- },
-
- /**
- * @param {bool} prepend - if true, prepend to beginning.
- * if false, then append to end
- */
- insertRow:function(prepend) {
- var modelRowIndex = (prepend) ? 0 : (this.grid.length - 1);
- var modelRow = this.grid[modelRowIndex];
-
- var newRow = new Array();
-
- var resolution = this.map.getResolution();
- var deltaY = (prepend) ? -this.tileSize.h : this.tileSize.h;
- var deltaLat = resolution * -deltaY;
-
- for (var i=0; i < modelRow.length; i++) {
- var modelTile = modelRow[i];
- var bounds = modelTile.bounds.copyOf();
- var position = modelTile.position.copyOf();
- bounds.bottom = bounds.bottom + deltaLat;
- bounds.top = bounds.top + deltaLat;
- position.y = position.y + deltaY;
- var newTile = this.addTile(bounds, position);
- newTile.draw((this.params.TRANSPARENT == 'true'));
- newRow.append(newTile);
- }
-
- if (newRow.length>0){
- if (prepend) {
- this.grid.prepend(newRow);
- } else {
- this.grid.append(newRow);
- }
- }
- },
-
- /**
- * @param {bool} prepend - if true, prepend to beginning.
- * if false, then append to end
- */
- insertColumn:function(prepend) {
- var modelCellIndex;
- var deltaX = (prepend) ? -this.tileSize.w : this.tileSize.w;
- var resolution = this.map.getResolution();
- var deltaLon = resolution * deltaX;
-
- for (var i=0; i<this.grid.length; i++) {
- var row = this.grid[i];
- modelTileIndex = (prepend) ? 0 : (row.length - 1);
- var modelTile = row[modelTileIndex];
-
- var bounds = modelTile.bounds.copyOf();
- var position = modelTile.position.copyOf();
- bounds.left = bounds.left + deltaLon;
- bounds.right = bounds.right + deltaLon;
- position.x = position.x + deltaX;
- var newTile = this.addTile(bounds, position);
- newTile.draw((this.params.TRANSPARENT == 'true'));
-
- if (prepend) {
- row = row.prepend(newTile);
- } else {
- row = row.append(newTile);
- }
- }
- },
- /** combine the ds's serverPath with its params and the tile's params.
- *
- * does checking on the serverPath variable, allowing for cases when it
- * is supplied with trailing ? or &, as well as cases where not.
- *
- * return in formatted string like this:
- * "server?key1=value1&key2=value2&key3=value3"
- *
- * @return {str}
- */
- getFullRequestString:function(params) {
- var requestString = "";
- this.params.SRS = this.map.projection;
- // concat tile params with layer params and convert to string
- var allParams = Object.extend(this.params, params);
- var paramsString = OpenLayers.Util.getParameterString(allParams);
-
- var server = this.url;
- var lastServerChar = server.charAt(server.length - 1);
-
- if ((lastServerChar == "&") || (lastServerChar == "?")) {
- requestString = server + paramsString;
- } else {
- if (server.indexOf('?') == -1) {
- //serverPath has no ? -- add one
- requestString = server + '?' + paramsString;
- } else {
- //serverPath contains ?, so must already have paramsString at the end
- requestString = server + '&' + paramsString;
- }
- }
- return requestString;
- },
-
- /** go through and remove all tiles from the grid, calling
- * destroy() on each of them to kill circular references
- *
- * @private
- */
- clearGrid:function() {
- if (this.grid) {
- while(this.grid.length > 0) {
- var row = this.grid[0];
- while(row.length > 0) {
- var tile = row[0];
- tile.destroy();
- row.remove(tile);
- }
- this.grid.remove(row);
- }
- }
- },
-
- /**
- * addTile gives subclasses of Grid the opportunity to create an
- * OpenLayer.Tile of their choosing. The implementer should initialize
- * the new tile and take whatever steps necessary to display it.
- *
- * @param {OpenLayers.Bounds} bounds
- *
- * @returns The added OpenLayers.Tile
- * @type OpenLayers.Tile
- */
- addTile:function(bounds,position) {
- // Should be implemented by subclasses
- },
-
- /** @final @type String */
- CLASS_NAME: "OpenLayers.Grid"
-});
+++ /dev/null
-/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
- * See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
- * text of the license. */
-// @require: OpenLayers/Layer/Grid.js
-/**
-* @class
-*/
-OpenLayers.Layer.KaMap = Class.create();
-OpenLayers.Layer.KaMap.prototype =
- Object.extend( new OpenLayers.Layer.Grid(), {
- metaTileHeight: 6,
- metaTileWidth: 6,
-
- DEFAULT_PARAMS: {
- i: 'jpeg',
- map: ''
- },
-
- // this.cellSize = newScale/(oMap.resolution * inchesPerUnit[oMap.units]);
- // kaMap.prototype.geoToPix = function( gX, gY ) { var pX = gX / this.cellSize; var pY = -1 * gY / this.cellSize; }
- initialize: function(name, url, params, origin) {
- this.kaOrigin = origin;
- var newArguments = new Array();
- newArguments.push(name, url, params);
- OpenLayers.Layer.Grid.prototype.initialize.apply(this, newArguments);
- this.params = (params ? params : {});
- if (arguments.length > 0 && params) {
- OpenLayers.Util.applyDefaults(
- this.params,
- this.DEFAULT_PARAMS
- );
- }
- },
- addTile:function(bounds,position) {
- var zoom = this.map.getZoom();
- var resolution = this.map.getResolution();
- var scale = 128000000 / Math.pow(2, zoom);
- // 1280000 is an empirical value for a specific tile server, not yet figured out the right way to do this in general.
- // This will probably be based on map.maxResolution.
- var cellSize = new OpenLayers.Size(resolution*this.tileSize.w, resolution*this.tileSize.h);
- var pX = Math.floor(((bounds.left + this.kaOrigin.lon) / cellSize.w) * this.tileSize.w);
- var pY = -Math.floor(((bounds.top+this.kaOrigin.lat) / cellSize.h) * this.tileSize.h);
- var url = this.getFullRequestString(
- { t: pY,
- l: pX,
- s: scale
- });
- return new OpenLayers.Tile.Image(this, position, bounds,
- url, this.tileSize);
- },
- /** @final @type String */
- CLASS_NAME: "OpenLayers.Layer.KaMap"
-});
+++ /dev/null
-/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
- * See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
- * text of the license. */
-// @require: OpenLayers/Layer.js
-/**
-* @class
-*/
-OpenLayers.Layer.Markers = Class.create();
-OpenLayers.Layer.Markers.prototype =
- Object.extend( new OpenLayers.Layer(), {
-
- /** internal marker list
- * @type Array(OpenLayers.Marker) */
- markers: null,
-
- /**
- * @constructor
- *
- * @param {String} name
- */
- initialize: function(name) {
- OpenLayers.Layer.prototype.initialize.apply(this, arguments);
- this.markers = new Array();
- },
-
- /**
- *
- */
- destroy: function() {
- this.clearMarkers();
- markers = null;
- OpenLayers.Layer.prototype.destroy.apply(this, arguments);
- },
-
-
- /**
- * @param {OpenLayers.Bounds} bounds
- * @param {Boolean} zoomChanged
- */
- moveTo: function(bounds, zoomChanged) {
- if (zoomChanged) {
- this.redraw();
- }
- },
-
- /** WFS layer is never a base class.
- * @type Boolean
- */
- isBaseLayer: function() {
- return false;
- },
-
- /**
- * @param {OpenLayers.Marker} marker
- */
- addMarker: function(marker) {
- this.markers.append(marker);
- if (this.map && this.map.getExtent()) {
- marker.map = this.map;
- this.drawMarker(marker);
- }
- },
-
- /**
- * @param {OpenLayers.Marker} marker
- */
- removeMarker: function(marker) {
- this.markers.remove(marker);
- if ((marker.icon != null) && (marker.icon.imageDiv != null) &&
- (marker.icon.imageDiv.parentNode == this.div) ) {
- this.div.removeChild(marker.icon.imageDiv);
- }
- },
-
- /**
- *
- */
- clearMarkers: function() {
- if (this.markers != null) {
- while(this.markers.length > 0) {
- this.removeMarker(this.markers[0]);
- }
- }
- },
-
- /** clear all the marker div's from the layer and then redraw all of them.
- * Use the map to recalculate new placement of markers.
- */
- redraw: function() {
- for(i=0; i < this.markers.length; i++) {
- this.drawMarker(this.markers[i]);
- }
- },
-
- /** Calculate the pixel location for the marker, create it, and
- * add it to the layer's div
- *
- * @private
- *
- * @param {OpenLayers.Marker} marker
- */
- drawMarker: function(marker) {
- var px = this.map.getLayerPxFromLonLat(marker.lonlat);
- var markerImg = marker.draw(px);
- if (!marker.drawn) {
- this.div.appendChild(markerImg);
- marker.drawn = true;
- }
- },
-
- /** @final @type String */
- CLASS_NAME: "OpenLayers.Layer.Markers"
-});
+++ /dev/null
-/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
- * See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
- * text of the license. */
-// @require: OpenLayers/Layer/Markers.js
-
-/**
-* @class
-*/
-OpenLayers.Layer.Text = Class.create();
-OpenLayers.Layer.Text.prototype =
- Object.extend( new OpenLayers.Layer.Markers(), {
-
- /** store url of text file
- * @type str */
- location:null,
-
- /** @type Array(OpenLayers.Feature) */
- features: null,
-
- /** @type OpenLayers.Feature */
- selectedFeature: null,
-
- /**
- * @constructor
- *
- * @param {String} name
- * @param {String} location
- */
- initialize: function(name, location) {
- OpenLayers.Layer.Markers.prototype.initialize.apply(this, [name]);
- this.location = location;
- this.features = new Array();
- new Ajax.Request(location,
- { method: 'get', onComplete:this.parseData.bind(this) } );
- },
-
- /**
- *
- */
- destroy: function() {
- this.clearFeatures();
- this.features = null;
- OpenLayers.Layer.Markers.prototype.destroy.apply(this, arguments);
- },
-
- /** WFS layer is never a base class.
- * @type Boolean
- */
- isBaseLayer: function() {
- return false;
- },
-
-
- /**
- * @param {?} ajaxRequest
- */
- parseData: function(ajaxRequest) {
- var text = ajaxRequest.responseText;
- var lines = text.split('\n');
- var columns;
- // length - 1 to allow for trailing new line
- for (var lcv = 0; lcv < (lines.length - 1); lcv++) {
- var currLine = lines[lcv].replace(/^\s*/,'').replace(/\s*$/,'');
-
- if (currLine.charAt(0) != '#') { /* not a comment */
-
- if (!columns) {
- //First line is columns
- columns = currLine.split('\t');
- } else {
- var vals = currLine.split('\t');
- var location = new OpenLayers.LonLat(0,0);
- var title; var url;
- var icon, iconSize, iconOffset;
- var set = false;
- for (var valIndex = 0; valIndex < vals.length; valIndex++) {
- if (vals[valIndex]) {
- if (columns[valIndex] == 'point') {
- var coords = vals[valIndex].split(',');
- location.lat = parseFloat(coords[0]);
- location.lon = parseFloat(coords[1]);
- set = true;
- } else if (columns[valIndex] == 'lat') {
- location.lat = parseFloat(vals[valIndex]);
- set = true;
- } else if (columns[valIndex] == 'lon') {
- location.lon = parseFloat(vals[valIndex]);
- set = true;
- } else if (columns[valIndex] == 'title')
- title = vals[valIndex];
- else if (columns[valIndex] == 'image' ||
- columns[valIndex] == 'icon')
- url = vals[valIndex];
- else if (columns[valIndex] == 'iconSize') {
- var size = vals[valIndex].split(',');
- iconSize = new OpenLayers.Size(parseFloat(size[0]),
- parseFloat(size[1]));
- } else if (columns[valIndex] == 'iconOffset') {
- var offset = vals[valIndex].split(',');
- iconOffset = new OpenLayers.Pixel(parseFloat(offset[0]),
- parseFloat(offset[1]));
- } else if (columns[valIndex] == 'title') {
- title = vals[valIndex];
- } else if (columns[valIndex] == 'description') {
- description = vals[valIndex];
- }
- }
- }
- if (set) {
- var data = new Object();
- if (url != null) {
- data.icon = new OpenLayers.Icon(url,
- iconSize,
- iconOffset);
- } else {
- data.icon = OpenLayers.Marker.defaultIcon();
-
- //allows for the case where the image url is not
- // specified but the size is. use a default icon
- // but change the size
- if (iconSize != null) {
- data.icon.setSize(iconSize);
- }
-
- }
- if ((title != null) && (description != null)) {
- data['popupContentHTML'] = '<h2>'+title+'</h2><p>'+description+'</p>';
- }
- var feature = new OpenLayers.Feature(this, location, data);
- this.features.append(feature);
- var marker = feature.createMarker();
- marker.events.register('click', feature, this.markerClick);
- this.addMarker(marker);
- }
- }
- }
- }
- },
-
- /**
- * @param {Event} evt
- */
- markerClick: function(evt) {
- sameMarkerClicked = (this == this.layer.selectedFeature);
- this.layer.selectedFeature = (!sameMarkerClicked) ? this : null;
- for(var i=0; i < this.layer.map.popups.length; i++) {
- this.layer.map.removePopup(this.layer.map.popups[i]);
- }
- if (!sameMarkerClicked) {
- this.layer.map.addPopup(this.createPopup());
- }
- Event.stop(evt);
- },
-
- /**
- *
- */
- clearFeatures: function() {
- if (this.features != null) {
- while(this.features.length > 0) {
- var feature = this.features[0];
- this.features.remove(feature);
- feature.destroy();
- }
- }
- },
-
- /** @final @type String */
- CLASS_NAME: "OpenLayers.Text"
-});
-
-
+++ /dev/null
-/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
- * See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
- * text of the license. */
-// @require: OpenLayers/Layer.js\r
-\r
-// load VE map control script\r
-document.write("<script src='http://dev.virtualearth.net/mapcontrol/v3/mapcontrol.js'></script>");\r
-\r
-\r
-/**\r
- * @class \r
- */\r
-OpenLayers.Layer.VirtualEarth = Class.create();\r
-OpenLayers.Layer.VirtualEarth.prototype = \r
- Object.extend( new OpenLayers.Layer(), {\r
-\r
- /** @type Boolean */\r
- viewPortLayer: true,\r
-\r
- /** @type VEMap */\r
- vemap: null,\r
- \r
- /**\r
- * @constructor\r
- * \r
- * @param {str} name\r
- */\r
- initialize:function(name) {\r
- OpenLayers.Layer.prototype.initialize.apply(this, arguments);\r
- },\r
-\r
- /** \r
- * @param {OpenLayers.Map} map\r
- */\r
- setMap:function(map) {\r
- OpenLayers.Layer.prototype.setMap.apply(this, arguments);\r
-\r
- // once our layer has been added to the map, we can create the vemap\r
- this.map.events.register("addlayer", this, this.loadVEMap);\r
- },\r
-\r
- /** Virtual Earth layer is always a base class. \r
- * @type Boolean\r
- */\r
- isBaseLayer: function() {\r
- return true;\r
- },\r
-\r
- /** \r
- * @param {OpenLayers.Bounds} bounds\r
- * @param {int} zoomChanged\r
- */\r
- moveTo:function(bounds,zoomChanged) {\r
-\r
- if (this.vemap != null) {\r
- var olCenter = this.map.getCenter();\r
- var olZoom = this.map.getZoom();\r
- \r
- this.vemap.SetCenterAndZoom(new VELatLong(olCenter.lat, olCenter.lon),\r
- olZoom + 1);\r
- }\r
- },\r
-\r
-\r
- /**\r
- * \r
- */\r
- loadVEMap:function() {\r
- // create div and set to same size as map\r
- var veDiv = OpenLayers.Util.createDiv(this.name);\r
- var sz = this.map.getSize();\r
- veDiv.style.width = sz.w;\r
- veDiv.style.height = sz.h;\r
- this.div.appendChild(veDiv);\r
-\r
- // create VEMap, hide nav controls\r
- this.vemap = new VEMap(this.name);\r
- this.vemap.LoadMap();\r
- this.vemap.HideDashboard();\r
-\r
- // catch pans and zooms from VE Map\r
- this.vemap.AttachEvent("onendcontinuouspan", \r
- this.catchPanZoom.bindAsEventListener(this)); \r
- this.vemap.AttachEvent("onendzoom", \r
- this.catchPanZoom.bindAsEventListener(this)); \r
- \r
-\r
- },\r
-\r
- /**\r
- * @param {event} e\r
- */\r
- catchPanZoom: function(e) { \r
- var veCenter = this.vemap.GetCenter();\r
- var veZoom = this.vemap.GetZoomLevel();\r
- \r
- var olCenter = new OpenLayers.LonLat(veCenter.Longitude,\r
- veCenter.Latitude);\r
- \r
- this.map.setCenter(olCenter, veZoom - 1);\r
- \r
- },\r
-\r
-\r
- /** @final @type String */\r
- CLASS_NAME: "OpenLayers.Layer.VirtualEarth"\r
-});
\ No newline at end of file
+++ /dev/null
-/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
- * See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
- * text of the license. */
-// @require: OpenLayers/Layer/Grid.js
-// @require: OpenLayers/Layer/Markers.js
-/**
-* @class
-*/
-OpenLayers.Layer.WFS = Class.create();
-OpenLayers.Layer.WFS.prototype =
- Object.extend(new OpenLayers.Layer.Grid(),
- Object.extend(new OpenLayers.Layer.Markers(), {
-
- /** @type Object */
- featureClass: OpenLayers.Feature.WFS,
-
- /** @final @type hash */
- DEFAULT_PARAMS: { service: "WFS",
- version: "1.0.0",
- request: "GetFeature",
- typename: "docpoint"
- },
-
- /**
- * @constructor
- *
- * @param {str} name
- * @param {str} url
- * @param {hash} params
- * @param {Object} featureClass
- */
- initialize: function(name, url, params, featureClass) {
- if (featureClass != null) this.featureClass = featureClass;
-
- var newArguments = new Array();
- if (arguments.length > 0) {
- //uppercase params
- params = OpenLayers.Util.upperCaseObject(params);
- newArguments.push(name, url, params);
- }
- OpenLayers.Layer.Grid.prototype.initialize.apply(this, newArguments);
- OpenLayers.Layer.Markers.prototype.initialize.apply(this, newArguments);
-
- if (arguments.length > 0) {
- OpenLayers.Util.applyDefaults(
- this.params,
- OpenLayers.Util.upperCaseObject(this.DEFAULT_PARAMS)
- );
- }
- },
-
-
- /**
- *
- */
- destroy: function() {
- OpenLayers.Layer.Grid.prototype.destroy.apply(this, arguments);
- OpenLayers.Layer.Markers.prototype.destroy.apply(this, arguments);
- },
-
- /**
- * @param {OpenLayers.Bounds} bounds
- * @param {Boolean} zoomChanged
- */
- moveTo: function(bounds, zoomChanged) {
- OpenLayers.Layer.Grid.prototype.moveTo.apply(this, arguments);
- OpenLayers.Layer.Markers.prototype.moveTo.apply(this, arguments);
- },
-
- /** WFS layer is never a base class.
- * @type Boolean
- */
- isBaseLayer: function() {
- return false;
- },
-
- /**
- * @param {String} name
- * @param {hash} params
- *
- * @returns A clone of this OpenLayers.Layer.WMS, with the passed-in
- * parameters merged in.
- * @type OpenLayers.Layer.WMS
- */
- clone: function (name, params) {
- var mergedParams = {}
- Object.extend(mergedParams, this.params);
- Object.extend(mergedParams, params);
- var obj = new OpenLayers.Layer.WFS(name, this.url, mergedParams);
- obj.setTileSize(this.tileSize);
- return obj;
- },
-
- /**
- * addTile creates a tile, initializes it (via 'draw' in this case), and
- * adds it to the layer div.
- *
- * @param {OpenLayers.Bounds} bounds
- *
- * @returns The added OpenLayers.Tile.WFS
- * @type OpenLayers.Tile.WFS
- */
- addTile:function(bounds, position) {
- url = this.getFullRequestString(
- { BBOX:bounds.toBBOX() });
-
- return new OpenLayers.Tile.WFS(this, position, bounds,
- url, this.tileSize);
- },
-
-
- /** @final @type String */
- CLASS_NAME: "OpenLayers.Layer.WFS"
-}
-)
-);
+++ /dev/null
-/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
- * See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
- * text of the license. */
-// @require: OpenLayers/Layer/Grid.js
-/**
-* @class
-*/
-OpenLayers.Layer.WMS = Class.create();
-OpenLayers.Layer.WMS.prototype =
- Object.extend( new OpenLayers.Layer.Grid(), {
-
- /** @final @type hash */
- DEFAULT_PARAMS: { service: "WMS",
- version: "1.1.1",
- request: "GetMap",
- styles: "",
- exceptions: "application/vnd.ogc.se_inimage",
- format: "image/jpeg"
- },
-
- /**
- * @constructor
- *
- * @param {str} name
- * @param {str} url
- * @param {hash} params
- */
- initialize: function(name, url, params) {
- var newArguments = new Array();
- if (arguments.length > 0) {
- //uppercase params
- params = OpenLayers.Util.upperCaseObject(params);
- newArguments.push(name, url, params);
- }
- OpenLayers.Layer.Grid.prototype.initialize.apply(this, newArguments);
-
- if (arguments.length > 0) {
- OpenLayers.Util.applyDefaults(
- this.params,
- OpenLayers.Util.upperCaseObject(this.DEFAULT_PARAMS)
- );
- }
- },
-
-
- /** WFS layer is never a base class.
- * @type Boolean
- */
- isBaseLayer: function() {
- return (this.params.TRANSPARENT != 'true');
- },
-
- /**
- * @param {String} name
- * @param {hash} params
- *
- * @returns A clone of this OpenLayers.Layer.WMS, with the passed-in
- * parameters merged in.
- * @type OpenLayers.Layer.WMS
- */
- clone: function (name, params) {
- var mergedParams = {};
- Object.extend(mergedParams, this.params);
- Object.extend(mergedParams, params);
- var obj = new OpenLayers.Layer.WMS(name, this.url, mergedParams);
- obj.setTileSize(this.tileSize);
- return obj;
- },
-
- /**
- * addTile creates a tile, initializes it (via 'draw' in this case), and
- * adds it to the layer div.
- *
- * @param {OpenLayers.Bounds} bounds
- *
- * @returns The added OpenLayers.Tile.Image
- * @type OpenLayers.Tile.Image
- */
- addTile:function(bounds,position) {
- url = this.getFullRequestString(
- {BBOX:bounds.toBBOX(),
- WIDTH:this.tileSize.w,
- HEIGHT:this.tileSize.h});
-
- return new OpenLayers.Tile.Image(this, position, bounds,
- url, this.tileSize);
- },
-
- /** @final @type String */
- CLASS_NAME: "OpenLayers.Layer.WMS"
-});
+++ /dev/null
-/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
- * See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
- * text of the license. */
-// @require: OpenLayers/Layer/Grid.js
-/**
-* @class
-*/
-OpenLayers.Layer.WMS.Untiled = Class.create();
-OpenLayers.Layer.WMS.Untiled.prototype =
- Object.extend( new OpenLayers.Layer.Grid(), {
-
- /** @final @type hash */
- DEFAULT_PARAMS: { service: "WMS",
- version: "1.1.1",
- request: "GetMap",
- styles: "",
- exceptions: "application/vnd.ogc.se_inimage",
- format: "image/jpeg"
- },
-
- /**
- * @constructor
- *
- * @param {str} name
- * @param {str} url
- * @param {hash} params
- */
- initialize: function(name, url, params) {
- var newArguments = new Array();
- if (arguments.length > 0) {
- //uppercase params
- params = OpenLayers.Util.upperCaseObject(params);
- newArguments.push(name, url, params);
- }
- OpenLayers.Layer.Grid.prototype.initialize.apply(this, newArguments);
-
- if (arguments.length > 0) {
- OpenLayers.Util.applyDefaults(
- this.params,
- OpenLayers.Util.upperCaseObject(this.DEFAULT_PARAMS)
- );
- }
- },
-
-
- /** WFS layer is never a base class.
- * @type Boolean
- */
- isBaseLayer: function() {
- return (this.params.TRANSPARENT != true);
- },
-
- /**
- * @param {String} name
- * @param {hash} params
- *
- * @returns A clone of this OpenLayers.Layer.WMS, with the passed-in
- * parameters merged in.
- * @type OpenLayers.Layer.WMS
- */
- clone: function (name, params) {
- var mergedParams = {};
- Object.extend(mergedParams, this.params);
- Object.extend(mergedParams, params);
- var obj = new OpenLayers.Layer.WMS(name, this.url, mergedParams);
- obj.setTileSize(this.tileSize);
- return obj;
- },
-
- /**
- * addTile creates a tile, initializes it (via 'draw' in this case), and
- * adds it to the layer div.
- *
- * @param {OpenLayers.Bounds} bounds
- *
- * @returns The added OpenLayers.Tile.Image
- * @type OpenLayers.Tile.Image
- */
- addTile:function(bounds,position) {
- url = this.getFullRequestString(
- {BBOX:bounds.toBBOX(),
- WIDTH:this.map.getSize().w,
- HEIGHT:this.map.getSize().h});
-
- return new OpenLayers.Tile.Image(this, position, bounds,
- url, this.map.getSize());
- },
- moveTo:function(bounds,zoomChanged, minor) {
- if (!minor) {
- this.div.innerHTML = "";
- tile = this.addTile(bounds, new OpenLayers.Pixel(-parseInt(this.map.layerContainerDiv.style.left), -parseInt(this.map.layerContainerDiv.style.top)));
- tile.draw();
- }
- },
- /** @final @type String */
- CLASS_NAME: "OpenLayers.Layer.WMS.Untiled"
-});
+++ /dev/null
-/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
- * See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
- * text of the license. */
-// @require: OpenLayers/Layer.js\r
-\r
-// load Yahoo map control script\r
-document.write("<script src='http://api.maps.yahoo.com/ajaxymap?v=3.0&appid=euzuro-openlayers'></script>");\r
-\r
-/**\r
- * @class\r
- */\r
-OpenLayers.Layer.Yahoo = Class.create();\r
-OpenLayers.Layer.Yahoo.prototype = Object.extend( new OpenLayers.Layer(), {\r
-\r
- /** @type Boolean */\r
- viewPortLayer: true,\r
-\r
- /** @type GMap2 gmap stores the Google Map element */\r
- ymap:null,\r
- \r
- /** @type Boolean */\r
- dragging:false,\r
- \r
- /** \r
- * @constructor\r
- * \r
- * @param {String} name\r
- */\r
- initialize: function(name) {\r
- OpenLayers.Layer.prototype.initialize.apply(this, [name]);\r
- },\r
- \r
- /** \r
- * @param {OpenLayers.Map} map\r
- */\r
- setMap:function(map) {\r
- OpenLayers.Layer.prototype.setMap.apply(this, arguments);\r
-\r
- // once our layer has been added to the map, we can create the vemap\r
- this.map.events.register("addlayer", this, this.loadYMap);\r
- },\r
-\r
- /** Yahoo layer is always a base class.\r
- * @type Boolean\r
- */\r
- isBaseLayer: function() {\r
- return true;\r
- },\r
- \r
- /** \r
- * @param {OpenLayers.Bounds} bounds\r
- * @param {int} zoomChanged\r
- */\r
- moveTo:function(bounds,zoomChanged) {\r
-\r
- if ((this.ymap != null) && (!this.dragging)) {\r
-\r
- var olCenter = this.map.getCenter();\r
- var yCenter = this.getYMapCenter();\r
- \r
- var olZoom = this.map.getZoom();\r
- var yZoom = this.ymap.getZoomLevel();\r
- \r
- if ((!olCenter.equals(yCenter)) || (( 16 - olZoom) != yZoom)) {\r
- this.ymap.drawZoomAndCenter(new YGeoPoint(olCenter.lat, olCenter.lon), \r
- 16 - olZoom);\r
- }\r
- }\r
- },\r
-\r
- /**\r
- * \r
- */\r
- loadYMap:function() {\r
- // create div and set to same size as map\r
- var yDiv = OpenLayers.Util.createDiv(this.name);\r
- var sz = this.map.getSize();\r
- yDiv.style.width = sz.w;\r
- yDiv.style.height = sz.h;\r
- this.div.appendChild(yDiv);\r
-\r
- // create GMap, hide nav controls\r
- this.ymap = new YMap(this.div);\r
-\r
- // catch pans and zooms from GMap\r
- YEvent.Capture(this.ymap, \r
- EventsList.endPan, \r
- this.catchPanZoom, \r
- this); \r
-\r
- // catch pans and zooms from GMap\r
- YEvent.Capture(this.ymap, \r
- EventsList.endAutoPan, \r
- this.catchPanZoom, \r
- this); \r
-\r
-\r
- // attach to the drag start and end and we´ll set a flag so that\r
- // we dont get recursivity. this is because the events fall through\r
- // the gmaps div and into the main layer div\r
- YEvent.Capture(this.ymap, \r
- EventsList.startPan, \r
- this.dragStart,\r
- this); \r
-\r
- },\r
-\r
- /** \r
- * @private\r
- */\r
- dragStart: function() {\r
- this.dragging = true;\r
- },\r
- \r
- /**\r
- * @private \r
- * \r
- * @param {event} e\r
- */\r
- catchPanZoom: function(e) { \r
- this.dragging = false;\r
-\r
- var olCenter = this.getYMapCenter();\r
- var yZoom = this.ymap.getZoomLevel();\r
-\r
- this.map.setCenter(olCenter, 16 - yZoom);\r
- \r
- },\r
-\r
- /**\r
- * @private\r
- * \r
- * @returns An OpenLayers.LonLat with the center of the ymap, or null if \r
- * the YMap has not been centered yet\r
- * @type OpenLayers.LonLat\r
- */\r
- getYMapCenter:function() {\r
- var olCenter = null;\r
- var yCenter = this.ymap.getCenterLatLon();\r
- if (yCenter != null) {\r
- olCenter = new OpenLayers.LonLat(yCenter.Lon, yCenter.Lat);\r
- }\r
- return olCenter;\r
- },\r
- \r
- \r
- /** @final @type String */\r
- CLASS_NAME: "OpenLayers.Layer.Yahoo"\r
-});\r
+++ /dev/null
-/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
- * See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
- * text of the license. */
-// @require: OpenLayers/Util.js
-/**
-* @class
-*
-*
-*/
-
-OpenLayers.Map = Class.create();
-OpenLayers.Map.prototype = {
- // Hash: base z-indexes for different classes of thing
- Z_INDEX_BASE: { Layer: 100, Popup: 200, Control: 1000 },
-
- // Array: supported application event types
- EVENT_TYPES: [
- "addlayer", "removelayer", "movestart", "move", "moveend",
- "zoomend", "layerchanged", "popupopen", "popupclose",
- "addmarker", "removemarker", "clearmarkers", "mouseover",
- "mouseout", "mousemove", "dragstart", "drag", "dragend" ],
-
- // int: zoom levels, used to draw zoom dragging control and limit zooming
- maxZoomLevel: 16,
-
- // OpenLayers.Bounds
- maxExtent: new OpenLayers.Bounds(-180, -90, 180, 90),
-
- /* projection */
- projection: "EPSG:4326",
-
- /** @type OpenLayers.Size */
- size: null,
-
- // float
- maxResolution: 1.40625, // degrees per pixel
- // Default is whole world in 256 pixels, from GMaps
-
- // DOMElement: the div that our map lives in
- div: null,
-
- // HTMLDivElement: the map's view port
- viewPortDiv: null,
-
- // HTMLDivElement: the map's layer container
- layerContainerDiv: null,
-
- // Array(OpenLayers.Layer): ordered list of layers in the map
- layers: null,
-
- // Array(OpenLayers.Control)
- controls: null,
-
- // Array(OpenLayers.Popup)
- popups: null,
-
- // OpenLayers.LonLat
- center: null,
-
- // int
- zoom: null,
-
- // OpenLayers.Events
- events: null,
-
- // OpenLayers.Pixel
- mouseDragStart: null,
-
- /** @type OpenLayers.Layer */
- baseLayer: null,
-
- /**
- * @param {DOMElement} div
- */
- initialize: function (div, options) {
- Object.extend(this, options);
-
- this.div = div = $(div);
-
- // the viewPortDiv is the outermost div we modify
- var id = div.id + "_OpenLayers_ViewPort";
- this.viewPortDiv = OpenLayers.Util.createDiv(id, null, null, null,
- "relative", null,
- "hidden");
- this.viewPortDiv.style.width = "100%";
- this.viewPortDiv.style.height = "100%";
- this.div.appendChild(this.viewPortDiv);
-
- // the layerContainerDiv is the one that holds all the layers
- id = div.id + "_OpenLayers_Container";
- this.layerContainerDiv = OpenLayers.Util.createDiv(id);
- this.viewPortDiv.appendChild(this.layerContainerDiv);
-
- this.events = new OpenLayers.Events(this, div, this.EVENT_TYPES);
-
- this.updateSize();
- // make the entire maxExtent fix in zoom level 0 by default
- if (this.maxResolution == null || this.maxResolution == "auto") {
- this.maxResolution = Math.max(
- this.maxExtent.getWidth() / this.size.w,
- this.maxExtent.getHeight() / this.size.h );
- }
- // update the internal size register whenever the div is resized
- this.events.register("resize", this, this.updateSize);
-
- this.layers = [];
-
- if (!this.controls) {
- this.controls = [];
- this.addControl(new OpenLayers.Control.MouseDefaults());
- this.addControl(new OpenLayers.Control.PanZoom());
- }
-
- this.popups = new Array();
-
- // always call map.destroy()
- Event.observe(window, 'unload',
- this.destroy.bindAsEventListener(this));
- },
-
- /**
- * @private
- */
- destroy:function() {
- if (this.layers != null) {
- for(var i=0; i< this.layers.length; i++) {
- this.layers[i].destroy();
- }
- this.layers = null;
- }
- if (this.controls != null) {
- for(var i=0; i< this.controls.length; i++) {
- this.controls[i].destroy();
- }
- this.controls = null;
- }
- },
-
- /**
- * @param {OpenLayers.Layer} layer
- */
- addLayer: function (layer) {
- layer.setMap(this);
- layer.div.style.overflow = "";
- layer.div.style.zIndex = this.Z_INDEX_BASE['Layer'] + this.layers.length;
-
- if (layer.viewPortLayer) {
- this.viewPortDiv.appendChild(layer.div);
- } else {
- this.layerContainerDiv.appendChild(layer.div);
- }
- this.layers.push(layer);
-
- // hack hack hack - until we add a more robust layer switcher,
- // which is able to determine which layers are base layers and
- // which are not (and put baselayers in a radiobutton group and
- // other layers in checkboxes) this seems to be the most straight-
- // forward way of dealing with this.
- //
- if (layer.isBaseLayer()) {
- this.baseLayer = layer;
- }
- this.events.triggerEvent("addlayer");
- },
-
- /** Removes a layer from the map by removing its visual element (the
- * layer.div property), then removing it from the map's internal list
- * of layers, setting the layer's map property to null.
- *
- * a "removelayer" event is triggered.
- *
- * very worthy of mention is that simply removing a layer from a map
- * will not cause the removal of any popups which may have been created
- * by the layer. this is due to the fact that it was decided at some
- * point that popups would not belong to layers. thus there is no way
- * for us to know here to which layer the popup belongs.
- *
- * A simple solution to this is simply to call destroy() on the layer.
- * the default OpenLayers.Layer class's destroy() function
- * automatically takes care to remove itself from whatever map it has
- * been attached to.
- *
- * The correct solution is for the layer itself to register an
- * event-handler on "removelayer" and when it is called, if it
- * recognizes itself as the layer being removed, then it cycles through
- * its own personal list of popups, removing them from the map.
- *
- * @param {OpenLayers.Layer} layer
- */
- removeLayer: function(layer) {
- this.layerContainerDiv.removeChild(layer.div);
- this.layers.remove(layer);
- layer.map = null;
- this.events.triggerEvent("removelayer");
- },
-
- /**
- * @param {Array(OpenLayers.Layer)} layers
- */
- addLayers: function (layers) {
- for (var i = 0; i < layers.length; i++) {
- this.addLayer(layers[i]);
- }
- },
-
- /**
- * @param {OpenLayers.Control} control
- * @param {OpenLayers.Pixel} px
- */
- addControl: function (control, px) {
- control.map = this;
- this.controls.push(control);
- var div = control.draw(px);
- if (div) {
- div.style.zIndex = this.Z_INDEX_BASE['Control'] +
- this.controls.length;
- this.viewPortDiv.appendChild( div );
- }
- },
-
- /**
- * @param {OpenLayers.Popup} popup
- */
- addPopup: function(popup) {
- popup.map = this;
- this.popups.push(popup);
- var popupDiv = popup.draw();
- if (popupDiv) {
- popupDiv.style.zIndex = this.Z_INDEX_BASE['Popup'] +
- this.popups.length;
- this.layerContainerDiv.appendChild(popupDiv);
- }
- },
-
- /**
- * @param {OpenLayers.Popup} popup
- */
- removePopup: function(popup) {
- this.popups.remove(popup);
- if (popup.div) {
- this.layerContainerDiv.removeChild(popup.div);
- }
- popup.map = null;
- },
-
- /**
- * @return {float}
- */
- getResolution: function () {
- // return degrees per pixel
- return this.maxResolution / Math.pow(2, this.zoom);
- },
-
- /**
- * @return {int}
- */
- getZoom: function () {
- return this.zoom;
- },
-
- /**
- * @returns {OpenLayers.Size}
- */
- getSize: function () {
- return this.size;
- },
-
- /**
- * @private
- */
- updateSize: function() {
- this.size = new OpenLayers.Size(
- this.div.clientWidth, this.div.clientHeight);
- this.events.div.offsets = null;
- // Workaround for the fact that hidden elements return 0 for size.
- if (this.size.w == 0 && this.size.h == 0) {
- var dim = Element.getDimensions(this.div);
- this.size.w = dim.width;
- this.size.h = dim.height;
- }
- if (this.size.w == 0 && this.size.h == 0) {
- this.size.w = parseInt(this.div.style.width);
- this.size.h = parseInt(this.div.style.height);
- }
- },
-
- /**
- * @return {OpenLayers.LonLat}
- */
- getCenter: function () {
- return this.center;
- },
-
- /**
- * @return {OpenLayers.Bounds}
- */
- getExtent: function () {
- if (this.center) {
- var res = this.getResolution();
- var size = this.getSize();
- var w_deg = size.w * res;
- var h_deg = size.h * res;
- return new OpenLayers.Bounds(
- this.center.lon - w_deg / 2,
- this.center.lat - h_deg / 2,
- this.center.lon + w_deg / 2,
- this.center.lat + h_deg / 2);
- } else {
- return null;
- }
- },
-
- /**
- * @return {OpenLayers.Bounds}
- */
- getFullExtent: function () {
- return this.maxExtent;
- },
-
- getZoomLevels: function() {
- return this.maxZoomLevel;
- },
-
- /**
- * @param {OpenLayers.Bounds} bounds
- *
- * @return {int}
- */
- getZoomForExtent: function (bounds) {
- var size = this.getSize();
- var width = bounds.getWidth();
- var height = bounds.getHeight();
- var deg_per_pixel = (width > height ? width / size.w : height / size.h);
- var zoom = Math.log(this.maxResolution / deg_per_pixel) / Math.log(2);
- return Math.floor(Math.min(Math.max(zoom, 0), this.getZoomLevels()));
- },
-
- /**
- * @param {OpenLayers.Pixel} layerPx
- *
- * @returns px translated into view port pixel coordinates
- * @type OpenLayers.Pixel
- * @private
- */
- getViewPortPxFromLayerPx:function(layerPx) {
- var viewPortPx = layerPx.copyOf();
-
- viewPortPx.x += parseInt(this.layerContainerDiv.style.left);
- viewPortPx.y += parseInt(this.layerContainerDiv.style.top);
-
- return viewPortPx;
- },
-
- /**
- * @param {OpenLayers.Pixel} viewPortPx
- *
- * @returns px translated into view port pixel coordinates
- * @type OpenLayers.Pixel
- * @private
- */
- getLayerPxFromViewPortPx:function(viewPortPx) {
- var layerPx = viewPortPx.copyOf();
-
- layerPx.x -= parseInt(this.layerContainerDiv.style.left);
- layerPx.y -= parseInt(this.layerContainerDiv.style.top);
-
- return layerPx;
- },
-
-
- /**
- * @param {OpenLayers.Pixel} px
- *
- * @return {OpenLayers.LonLat}
- */
- getLonLatFromLayerPx: function (px) {
- //adjust for displacement of layerContainerDiv
- px = this.getViewPortPxFromLayerPx(px);
- return this.getLonLatFromViewPortPx(px);
- },
-
- /**
- * @param {OpenLayers.Pixel} viewPortPx
- *
- * @returns An OpenLayers.LonLat which is the passed-in view port
- * OpenLayers.Pixel, translated into lon/lat given the
- * current extent and resolution
- * @type OpenLayers.LonLat
- * @private
- */
- getLonLatFromViewPortPx: function (viewPortPx) {
- var center = this.getCenter(); //map center lon/lat
- var res = this.getResolution();
- var size = this.getSize();
-
- var delta_x = viewPortPx.x - (size.w / 2);
- var delta_y = viewPortPx.y - (size.h / 2);
-
- return new OpenLayers.LonLat(center.lon + delta_x * res ,
- center.lat - delta_y * res);
- },
-
- // getLonLatFromPixel is a convenience function for the API
- /**
- * @param {OpenLayers.Pixel} pixel
- *
- * @returns An OpenLayers.LonLat corresponding to the given
- * OpenLayers.Pixel, translated into lon/lat using the
- * current extent and resolution
- * @type OpenLayers.LonLat
- */
- getLonLatFromPixel: function (px) {
- return this.getLonLatFromViewPortPx(px);
- },
-
- /**
- * @param {OpenLayers.LonLat} lonlat
- *
- * @returns An OpenLayers.Pixel which is the passed-in OpenLayers.LonLat,
- * translated into layer pixels given the current extent
- * and resolution
- * @type OpenLayers.Pixel
- */
- getLayerPxFromLonLat: function (lonlat) {
- //adjust for displacement of layerContainerDiv
- var px = this.getViewPortPxFromLonLat(lonlat);
- return this.getLayerPxFromViewPortPx(px);
- },
-
- /**
- * @param {OpenLayers.LonLat} lonlat
- *
- * @returns An OpenLayers.Pixel which is the passed-in OpenLayers.LonLat,
- * translated into view port pixels given the current extent
- * and resolution
- * @type OpenLayers.Pixel
- * @private
- */
- getViewPortPxFromLonLat: function (lonlat) {
- var resolution = this.getResolution();
- var extent = this.getExtent();
- return new OpenLayers.Pixel(
- Math.round(1/resolution * (lonlat.lon - extent.left)),
- Math.round(1/resolution * (extent.top - lonlat.lat))
- );
- },
-
- // getLonLatFromPixel is a convenience function for the API
- /**
- * @param {OpenLayers.LonLat} lonlat
- *
- * @returns An OpenLayers.Pixel corresponding to the OpenLayers.LonLat
- * translated into view port pixels using the current extent
- * and resolution
- * @type OpenLayers.Pixel
- */
- getPixelFromLonLat: function (lonlat) {
- return this.getViewPortPxFromLonLat(lonlat);
- },
-
- /**
- * @param {OpenLayers.LonLat} lonlat
- * @param {int} zoom
- */
- setCenter: function (lonlat, zoom, minor) {
- if (this.center) { // otherwise there's nothing to move yet
- this.moveLayerContainer(lonlat);
- }
- this.center = lonlat.copyOf();
- var zoomChanged = null;
- if (zoom != null && zoom != this.zoom
- && zoom >= 0 && zoom <= this.getZoomLevels()) {
- zoomChanged = (this.zoom == null ? 0 : this.zoom);
- this.zoom = zoom;
- }
-
- if (!minor) this.events.triggerEvent("movestart");
- this.moveToNewExtent(zoomChanged, minor);
- if (!minor) this.events.triggerEvent("moveend");
- },
-
- /**
- * ZOOM TO BOUNDS FUNCTION
- * @private
- */
- moveToNewExtent: function (zoomChanged, minor) {
- if (zoomChanged != null) { // reset the layerContainerDiv's location
- this.layerContainerDiv.style.left = "0px";
- this.layerContainerDiv.style.top = "0px";
-
- //redraw popups
- for (var i = 0; i < this.popups.length; i++) {
- this.popups[i].updatePosition();
- }
-
- }
- var bounds = this.getExtent();
- for (var i = 0; i < this.layers.length; i++) {
- this.layers[i].moveTo(bounds, (zoomChanged != null), minor);
- }
- this.events.triggerEvent("move");
- if (zoomChanged != null)
- this.events.triggerEvent("zoomend",
- {oldZoom: zoomChanged, newZoom: this.zoom});
- },
-
- /**
- * zoomIn
- * Increase zoom level by one.
- * @param {int} zoom
- */
- zoomIn: function() {
- if (this.zoom != null && this.zoom <= this.getZoomLevels()) {
- this.zoomTo( this.zoom += 1 );
- }
- },
-
- /**
- * zoomTo
- * Set Zoom To int
- * @param {int} zoom
- */
- zoomTo: function(zoom) {
- if (zoom >= 0 && zoom <= this.getZoomLevels()) {
- var oldZoom = this.zoom;
- this.zoom = zoom;
- this.moveToNewExtent(oldZoom);
- }
- },
-
- /**
- * zoomOut
- * Decrease zoom level by one.
- * @param {int} zoom
- */
- zoomOut: function() {
- if (this.zoom != null && this.zoom > 0) {
- this.zoomTo( this.zoom - 1 );
- }
- },
-
- /**
- * zoomToFullExtent
- * Zoom to the full extent and recenter.
- */
- zoomToFullExtent: function() {
- var fullExtent = this.getFullExtent();
- this.setCenter(
- new OpenLayers.LonLat((fullExtent.left+fullExtent.right)/2,
- (fullExtent.bottom+fullExtent.top)/2),
- this.getZoomForExtent(fullExtent)
- );
- },
-
- /**
- * @param {OpenLayers.LonLat} lonlat
- * @private
- */
- moveLayerContainer: function (lonlat) {
- var container = this.layerContainerDiv;
- var resolution = this.getResolution();
-
- var deltaX = Math.round((this.center.lon - lonlat.lon) / resolution);
- var deltaY = Math.round((this.center.lat - lonlat.lat) / resolution);
-
- var offsetLeft = parseInt(container.style.left);
- var offsetTop = parseInt(container.style.top);
-
- container.style.left = (offsetLeft + deltaX) + "px";
- container.style.top = (offsetTop - deltaY) + "px";
- },
-
- CLASS_NAME: "OpenLayers.Map"
-};
+++ /dev/null
-/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
- * See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
- * text of the license. */
-/**
-* @class
-*/
-OpenLayers.Marker = Class.create();
-OpenLayers.Marker.prototype = {
-
- /** @type OpenLayers.Icon */
- icon: null,
-
- /** location of object
- * @type OpenLayers.LonLat */
- lonlat: null,
-
- /** @type OpenLayers.Events*/
- events: null,
-
- /** @type OpenLayers.Map */
- map: null,
-
- /**
- * @constructor
- *
- * @param {OpenLayers.Icon} icon
- * @param {OpenLayers.LonLat lonlat
- */
- initialize: function(lonlat, icon) {
- this.lonlat = lonlat;
- this.icon = (icon) ? icon : OpenLayers.Marker.defaultIcon();
-
- this.events = new OpenLayers.Events(this, this.icon.imageDiv, null);
- },
-
- destroy: function() {
- this.map = null;
-
- if (this.icon != null) {
- this.icon.destroy();
- this.icon = null;
- }
- },
-
- /**
- * @param {OpenLayers.Pixel} px
- *
- * @return A new DOM Image with this marker´s icon set at the
- * location passed-in
- * @type DOMElement
- */
- draw: function(px) {
- return this.icon.draw(px);
- },
-
- /**
- * @param {OpenLayers.Pixel} px
- */
- moveTo: function (px) {
- if ((px != null) && (this.icon != null)) {
- this.icon.moveTo(px);
- }
- },
-
- /**
- * @returns Whether or not the marker is currently visible on screen.
- * @type Boolean
- */
- onScreen:function() {
-
- var onScreen = false;
- if (this.map) {
- var screenBounds = this.map.getExtent();
- onScreen = screenBounds.contains(this.lonlat.lon, this.lonlat.lat);
- }
- return onScreen;
- },
-
- /**
- * @param {float} inflate
- */
- inflate: function(inflate) {
- if (this.icon) {
- var newSize = new OpenLayers.Size(this.icon.size.w * inflate,
- this.icon.size.h * inflate);
- this.icon.setSize(newSize);
- }
- },
-
- /** @final @type String */
- CLASS_NAME: "OpenLayers.Marker"
-};
-
-
-/**
- * @returns A default OpenLayers.Icon to use for a marker
- * @type OpenLayers.Icon
- */
-OpenLayers.Marker.defaultIcon = function() {
- var url = OpenLayers.Util.getImagesLocation() + "marker.png";
- var size = new OpenLayers.Size(21, 25);
- var calculateOffset = function(size) {
- return new OpenLayers.Pixel(-(size.w/2), -size.h);
- };
-
- return new OpenLayers.Icon(url, size, null, calculateOffset);
-};
-
-
+++ /dev/null
-/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
- * See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
- * text of the license. */
-/**\r
-* @class\r
-*/\r
-OpenLayers.Popup = Class.create();\r
-\r
-OpenLayers.Popup.count = 0;\r
-OpenLayers.Popup.WIDTH = 200;\r
-OpenLayers.Popup.HEIGHT = 200;\r
-OpenLayers.Popup.COLOR = "white";\r
-OpenLayers.Popup.OPACITY = 1;\r
-OpenLayers.Popup.BORDER = "0px";\r
-\r
-OpenLayers.Popup.prototype = {\r
-\r
- /** @type OpenLayers.Events*/\r
- events: null,\r
- \r
- /** @type String */\r
- id: "",\r
-\r
- /** @type OpenLayers.LonLat */\r
- lonlat: null,\r
-\r
- /** @type DOMElement */\r
- div: null,\r
-\r
- /** @type OpenLayers.Size*/\r
- size: null, \r
-\r
- /** @type String */\r
- contentHTML: "",\r
- \r
- /** @type String */\r
- backgroundColor: "",\r
- \r
- /** @type float */\r
- opacity: "",\r
-\r
- /** @type String */\r
- border: "",\r
-\r
- /** this gets set in Map.js when the popup is added to the map\r
- * @type OpenLayers.Map */\r
- map: null,\r
-\r
- /** \r
- * @constructor\r
- * \r
- * @param {String} id\r
- * @param {OpenLayers.LonLat} lonlat\r
- * @param {OpenLayers.Size} size\r
- * @param {String} contentHTML\r
- */\r
- initialize:function(id, lonlat, size, contentHTML) {\r
- OpenLayers.Popup.count += 1;\r
- this.id = (id != null) ? id : "Popup" + OpenLayers.Popup.count;\r
- this.lonlat = lonlat;\r
- this.size = (size != null) ? size \r
- : new OpenLayers.Size(\r
- OpenLayers.Popup.WIDTH,\r
- OpenLayers.Popup.HEIGHT);\r
- if (contentHTML != null) { \r
- this.contentHTML = contentHTML;\r
- }\r
- this.backgroundColor = OpenLayers.Popup.COLOR;\r
- this.opacity = OpenLayers.Popup.OPACITY;\r
- this.border = OpenLayers.Popup.BORDER;\r
-\r
- this.div = OpenLayers.Util.createDiv(this.id + "_div", null, null, \r
- null, null, null, "hidden");\r
-\r
- this.events = new OpenLayers.Events(this, this.div, null);\r
- },\r
-\r
- /** \r
- */\r
- destroy: function() {\r
- if (this.map != null) {\r
- this.map.removePopup(this);\r
- }\r
- this.div = null;\r
- this.map = null;\r
- },\r
-\r
- /** \r
- * @param {OpenLayers.Pixel} px\r
- * \r
- * @returns Reference to a div that contains the drawn popup\r
- * @type DOMElement\r
- */\r
- draw: function(px) {\r
- if (px == null) {\r
- if ((this.lonlat != null) && (this.map != null)) {\r
- px = this.map.getLayerPxFromLonLat(this.lonlat);\r
- }\r
- }\r
- \r
- this.setSize();\r
- this.setBackgroundColor();\r
- this.setOpacity();\r
- this.setBorder();\r
- this.setContentHTML();\r
- this.moveTo(px);\r
-\r
- return this.div;\r
- },\r
-\r
- /** \r
- * if the popup has a lonlat and its map members set, \r
- * then have it move itself to its proper position\r
- */\r
- updatePosition: function() {\r
- if ((this.lonlat) && (this.map)) {\r
- var px = this.map.getLayerPxFromLonLat(this.lonlat);\r
- this.moveTo(px); \r
- }\r
- },\r
-\r
- /**\r
- * @param {OpenLayers.Pixel} px\r
- */\r
- moveTo: function(px) {\r
- if ((px != null) && (this.div != null)) {\r
- this.div.style.left = px.x + "px";\r
- this.div.style.top = px.y + "px";\r
- }\r
- },\r
-\r
- /**\r
- * @returns Boolean indicating whether or not the popup is visible\r
- * @type Boolean\r
- */\r
- visible: function() {\r
- return Element.visible(this.div);\r
- },\r
-\r
- /**\r
- * \r
- */\r
- toggle: function() {\r
- Element.toggle(this.div);\r
- },\r
-\r
- /**\r
- *\r
- */\r
- show: function() {\r
- Element.show(this.div);\r
- },\r
-\r
- /**\r
- *\r
- */\r
- hide: function() {\r
- Element.hide(this.div);\r
- },\r
-\r
- /**\r
- * @param {OpenLayers.Size} size\r
- */\r
- setSize:function(size) { \r
- if (size != undefined) {\r
- this.size = size; \r
- }\r
- \r
- if (this.div != null) {\r
- this.div.style.width = this.size.w;\r
- this.div.style.height = this.size.h;\r
- }\r
- }, \r
-\r
- /**\r
- * @param {String} color\r
- */\r
- setBackgroundColor:function(color) { \r
- if (color != undefined) {\r
- this.backgroundColor = color; \r
- }\r
- \r
- if (this.div != null) {\r
- this.div.style.backgroundColor = this.backgroundColor;\r
- }\r
- }, \r
- \r
- /**\r
- * @param {float} opacity\r
- */\r
- setOpacity:function(opacity) { \r
- if (opacity != undefined) {\r
- this.opacity = opacity; \r
- }\r
- \r
- if (this.div != null) {\r
- // for Mozilla and Safari\r
- this.div.style.opacity = this.opacity;\r
-\r
- // for IE\r
- this.div.style.filter = 'alpha(opacity=' + this.opacity*100 + ')';\r
- }\r
- }, \r
- \r
- /**\r
- * @param {int} border\r
- */\r
- setBorder:function(border) { \r
- if (border != undefined) {\r
- this.border = border;\r
- }\r
- \r
- if (this.div != null) {\r
- this.div.style.border = this.border;\r
- }\r
- }, \r
- \r
- /**\r
- * @param {String} contentHTML\r
- */\r
- setContentHTML:function(contentHTML) {\r
- if (contentHTML != null) {\r
- this.contentHTML = contentHTML;\r
- }\r
- \r
- if (this.div != null) {\r
- this.div.innerHTML = this.contentHTML;\r
- } \r
- },\r
-\r
- CLASS_NAME: "OpenLayers.Popup"\r
-};\r
+++ /dev/null
-/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
- * See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
- * text of the license. */
-// @require: OpenLayers/Popup.js\r
-\r
-/**\r
-* @class\r
-*/\r
-OpenLayers.Popup.Anchored = Class.create();\r
-OpenLayers.Popup.Anchored.prototype =\r
- Object.extend( new OpenLayers.Popup(), {\r
-\r
- /** "lr", "ll", "tr", "tl" - relative position of the popup.\r
- * @type String */\r
- relativePosition: null,\r
-\r
- /** Object which must have expose a 'size' (OpenLayers.Size) and \r
- * 'offset' (OpenLayers.Pixel) \r
- * @type Object */\r
- anchor: null,\r
-\r
- /** \r
- * @constructor\r
- * \r
- * @param {String} id\r
- * @param {OpenLayers.LonLat} lonlat\r
- * @param {OpenLayers.Size} size\r
- * @param {String} contentHTML\r
- * @param {Object} anchor Object which must expose a \r
- * - 'size' (OpenLayers.Size) and \r
- * - 'offset' (OpenLayers.Pixel) \r
- * (this is generally an OpenLayers.Icon)\r
- */\r
- initialize:function(id, lonlat, size, contentHTML, anchor) {\r
- var newArguments = new Array(id, lonlat, size, contentHTML);\r
- OpenLayers.Popup.prototype.initialize.apply(this, newArguments);\r
-\r
- this.anchor = (anchor != null) ? anchor \r
- : { size: new OpenLayers.Size(0,0),\r
- offset: new OpenLayers.Pixel(0,0)};\r
- },\r
-\r
- /** \r
- * @param {OpenLayers.Pixel} px\r
- * \r
- * @returns Reference to a div that contains the drawn popup\r
- * @type DOMElement\r
- */\r
- draw: function(px) {\r
- if (px == null) {\r
- if ((this.lonlat != null) && (this.map != null)) {\r
- px = this.map.getLayerPxFromLonLat(this.lonlat);\r
- }\r
- }\r
- \r
- //calculate relative position\r
- this.relativePosition = this.calculateRelativePosition(px);\r
- \r
- return OpenLayers.Popup.prototype.draw.apply(this, arguments);\r
- },\r
- \r
- /** \r
- * @private\r
- * \r
- * @param {OpenLayers.Pixel} px\r
- * \r
- * @returns The relative position ("br" "tr" "tl "bl") at which the popup\r
- * should be placed\r
- * @type String\r
- */\r
- calculateRelativePosition:function(px) {\r
- var lonlat = this.map.getLonLatFromLayerPx(px); \r
- \r
- var extent = this.map.getExtent();\r
- var quadrant = extent.determineQuadrant(lonlat);\r
- \r
- return OpenLayers.Bounds.oppositeQuadrant(quadrant);\r
- }, \r
-\r
- /**\r
- * @param {OpenLayers.Pixel} px\r
- */\r
- moveTo: function(px) {\r
- \r
- var newPx = this.calculateNewPx(px);\r
- \r
- var newArguments = new Array(newPx); \r
- OpenLayers.Popup.prototype.moveTo.apply(this, newArguments);\r
- },\r
- \r
- /**\r
- * @param {OpenLayers.Size} size\r
- */\r
- setSize:function(size) { \r
- OpenLayers.Popup.prototype.setSize.apply(this, arguments);\r
-\r
- if ((this.lonlat) && (this.map)) {\r
- var px = this.map.getLayerPxFromLonLat(this.lonlat);\r
- this.moveTo(px);\r
- }\r
- }, \r
- \r
- /** \r
- * @private \r
- * \r
- * @param {OpenLayers.Pixel} px\r
- * \r
- * @returns The the new px position of the popup on the screen\r
- * relative to the passed-in px\r
- * @type OpenLayers.Pixel\r
- */\r
- calculateNewPx:function(px) {\r
- var newPx = px.offset(this.anchor.offset);\r
-\r
- var top = (this.relativePosition.charAt(0) == 't');\r
- newPx.y += (top) ? -this.size.h : this.anchor.size.h;\r
- \r
- var left = (this.relativePosition.charAt(1) == 'l');\r
- newPx.x += (left) ? -this.size.w : this.anchor.size.w;\r
-\r
- return newPx; \r
- },\r
-\r
- CLASS_NAME: "OpenLayers.Popup.Anchored"\r
-});\r
+++ /dev/null
-/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
- * See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
- * text of the license. */
-// @require: OpenLayers/Popup/Anchored.js\r
-\r
-/**\r
-* @class\r
-*/\r
-OpenLayers.Popup.AnchoredBubble = Class.create();\r
-\r
-//Border space for the rico corners\r
-OpenLayers.Popup.AnchoredBubble.CORNER_SIZE = 5;\r
-\r
-OpenLayers.Popup.AnchoredBubble.prototype =\r
- Object.extend( new OpenLayers.Popup.Anchored(), {\r
-\r
- /** @type DOMElement */\r
- contentDiv:null,\r
-\r
- \r
- /** \r
- * @constructor\r
- * \r
- * @param {String} id\r
- * @param {OpenLayers.LonLat} lonlat\r
- * @param {OpenLayers.Size} size\r
- * @param {String} contentHTML\r
- * @param {Object} anchor Object which must expose a \r
- * - 'size' (OpenLayers.Size) and \r
- * - 'offset' (OpenLayers.Pixel) \r
- * (this is generally an OpenLayers.Icon)\r
- */\r
- initialize:function(id, lonlat, size, contentHTML, anchor) {\r
- OpenLayers.Popup.Anchored.prototype.initialize.apply(this, arguments);\r
- },\r
-\r
- /** \r
- * @param {OpenLayers.Pixel} px\r
- * \r
- * @returns Reference to a div that contains the drawn popup\r
- * @type DOMElement\r
- */\r
- draw: function(px) {\r
- \r
- OpenLayers.Popup.Anchored.prototype.draw.apply(this, arguments);\r
-\r
- // make the content Div\r
- var contentSize = this.size.copyOf();\r
- contentSize.h -= (2 * OpenLayers.Popup.AnchoredBubble.CORNER_SIZE);\r
-\r
- var id = this.div.id + "-contentDiv";\r
- this.contentDiv = OpenLayers.Util.createDiv(id, null, contentSize, \r
- null, "relative", null,\r
- "hidden");\r
- this.div.appendChild(this.contentDiv);\r
- this.setContentHTML();\r
- \r
- this.setRicoCorners(true);\r
- \r
- //set the popup color and opacity \r
- this.setBackgroundColor(); \r
- this.setOpacity();\r
-\r
- return this.div;\r
- },\r
-\r
- /**\r
- * @param {OpenLayers.Size} size\r
- */\r
- setSize:function(size) { \r
- OpenLayers.Popup.Anchored.prototype.setSize.apply(this, arguments);\r
- \r
- if (this.contentDiv != null) {\r
-\r
- var contentSize = this.size.copyOf();\r
- contentSize.h -= (2 * OpenLayers.Popup.AnchoredBubble.CORNER_SIZE);\r
- \r
- this.contentDiv.style.height = contentSize.h + "px";\r
- \r
- //size has changed - must redo corners \r
- this.setRicoCorners(false);\r
- }\r
- }, \r
-\r
- /**\r
- * @param {String} color\r
- */\r
- setBackgroundColor:function(color) { \r
- if (color != undefined) {\r
- this.backgroundColor = color; \r
- }\r
- \r
- if (this.div != null) {\r
- if (this.contentDiv != null) {\r
- this.div.style.background = "transparent";\r
- Rico.Corner.changeColor(this.contentDiv, this.backgroundColor);\r
- }\r
- }\r
- }, \r
- \r
- /**\r
- * @param {float} opacity\r
- */\r
- setOpacity:function(opacity) { \r
- if (opacity != undefined) {\r
- this.opacity = opacity; \r
- }\r
- \r
- if (this.div != null) {\r
- if (this.contentDiv != null) {\r
- Rico.Corner.changeOpacity(this.contentDiv, this.opacity);\r
- }\r
- }\r
- }, \r
- \r
- /** Bubble Popups can not have a border\r
- * \r
- * @param {int} border\r
- */\r
- setBorder:function(border) { \r
- this.border = 0;\r
- }, \r
- \r
- /**\r
- * @param {String} contentHTML\r
- */\r
- setContentHTML:function(contentHTML) {\r
- if (contentHTML != null) {\r
- this.contentHTML = contentHTML;\r
- }\r
- \r
- if (this.contentDiv != null) {\r
- this.contentDiv.innerHTML = this.contentHTML;\r
- } \r
- },\r
- \r
- /** \r
- * @private\r
- * \r
- * @param {Boolean} firstTime Is this the first time the corners are being\r
- * rounded?\r
- * \r
- * update the rico corners according to the popup's\r
- * current relative postion \r
- */\r
- setRicoCorners:function(firstTime) {\r
- \r
- var corners = this.getCornersToRound(this.relativePosition);\r
- var options = {corners: corners,\r
- color: this.backgroundColor,\r
- bgColor: "transparent",\r
- blend: false};\r
-\r
- if (firstTime) {\r
- Rico.Corner.round(this.div, options);\r
- } else {\r
- Rico.Corner.reRound(this.contentDiv, options);\r
- //set the popup color and opacity\r
- this.setBackgroundColor(); \r
- this.setOpacity();\r
- }\r
- },\r
-\r
- /** \r
- * @private\r
- * \r
- * @returns The proper corners string ("tr tl bl br") for rico\r
- * to round\r
- * @type String\r
- */\r
- getCornersToRound:function() {\r
-\r
- var corners = ['tl', 'tr', 'bl', 'br'];\r
-\r
- //we want to round all the corners _except_ the opposite one. \r
- var corner = OpenLayers.Bounds.oppositeQuadrant(this.relativePosition);\r
- corners.remove(corner);\r
-\r
- return corners.join(" ");\r
- },\r
-\r
- CLASS_NAME: "OpenLayers.Popup.AnchoredBubble"\r
-});\r
+++ /dev/null
-/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
- * See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
- * text of the license. */
-_OPENLAYERS_SFL_=true
-
+++ /dev/null
-/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
- * See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
- * text of the license. */
-/*
- * OpenLayers.Tile
- *
- * @class This is a class designed to designate a single tile, however
- * it is explicitly designed to do relatively little. Tiles store information
- * about themselves -- such as the URL that they are related to, and their
- * size - but do not add themselves to the layer div automatically, for
- * example.
- */
-OpenLayers.Tile = Class.create();
-OpenLayers.Tile.prototype = {
-
- /** @type OpenLayers.Layer */
- layer: null,
-
- /** @type String url of the request */
- url:null,
-
- /** @type OpenLayers.Bounds */
- bounds:null,
-
- /** @type OpenLayers.Size */
- size:null,
-
- /** Top Left pixel of the tile
- * @type OpenLayers.Pixel */
- position:null,
-
- /**
- * @constructor
- *
- * @param {OpenLayers.Layer} layer
- * @param {OpenLayers.Pixel} position
- * @param {OpenLayers.Bounds} bounds
- * @param {String} url
- * @param {OpenLayers.Size} size
- */
- initialize: function(layer, position, bounds, url, size) {
- if (arguments.length > 0) {
- this.layer = layer;
- this.position = position;
- this.bounds = bounds;
- this.url = url;
- this.size = size;
- }
- },
-
- /** nullify references to prevent circular references and memory leaks
- */
- destroy:function() {
- this.layer = null;
- this.bounds = null;
- this.size = null;
- },
-
- /**
- */
- draw:function() {
-
- // HACK HACK - should we make it a standard to put this sort of warning
- // message in functions that are supposed to be overridden?
- //
- // Log.warn(this.CLASS_NAME + ": draw() not implemented");
-
- },
-
- /** remove this tile from the ds
- */
- remove:function() {
- },
-
- /**
- * @type OpenLayers.Pixel
- */
- getPosition: function() {
- return this.position;
- },
-
- /** @final @type String */
- CLASS_NAME: "OpenLayers.Tile"
-};
-
+++ /dev/null
-/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
- * See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
- * text of the license. */
-// @require: OpenLayers/Tile.js
-/**
-* @class
-*/
-OpenLayers.Tile.Image = Class.create();
-OpenLayers.Tile.Image.prototype =
- Object.extend( new OpenLayers.Tile(), {
-
- /** @type DOMElement img */
- imgDiv:null,
-
- /**
- * @constructor
- *
- * @param {OpenLayers.Grid} layer
- * @param {OpenLayers.Pixel} position
- * @param {OpenLayers.Bounds} bounds
- * @param {String} url
- * @param {OpenLayers.Size} size
- */
- initialize: function(layer, position, bounds, url, size) {
- OpenLayers.Tile.prototype.initialize.apply(this, arguments);
- },
-
- destroy: function() {
- if ((this.imgDiv != null) && (this.imgDiv.parentNode == this.layer.div)) {
- this.layer.div.removeChild(this.imgDiv);
- }
- this.imgDiv = null;
- OpenLayers.Tile.prototype.destroy.apply(this, arguments);
- },
-
- /**
- */
- draw:function(transparent) {
- if (false) { // don't actually use the alpha PNG hack right now
- // it has a fiercely bad effect on IE6's performance
- // if (transparent) {
- this.imgDiv = OpenLayers.Util.createAlphaImageDiv(null,
- this.position,
- this.size,
- this.url,
- "absolute");
- } else {
- this.imgDiv = OpenLayers.Util.createImage(null,
- this.position,
- this.size,
- this.url,
- "absolute");
- }
- this.layer.div.appendChild(this.imgDiv);
- },
-
- /** @final @type String */
- CLASS_NAME: "OpenLayers.Tile.Image"
- }
-);
+++ /dev/null
-/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
- * See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
- * text of the license. */
-// @require: OpenLayers/Tile.js
-/**
-* @class
-*/
-OpenLayers.Tile.WFS = Class.create();
-OpenLayers.Tile.WFS.prototype =
- Object.extend( new OpenLayers.Tile(), {
-
- /** @type Array(OpenLayers.Feature)*/
- features: null,
-
-
- /**
- * @constructor
- *
- * @param {OpenLayers.Layer} layer
- * @param {OpenLayers.Pixel} position
- * @param {OpenLayers.Bounds} bounds
- * @param {String} url
- * @param {OpenLayers.Size} size
- */
- initialize: function(layer, position, bounds, url, size) {
- OpenLayers.Tile.prototype.initialize.apply(this, arguments);
-
- this.features = new Array();
- },
-
- /**
- *
- */
- destroy: function() {
- for(var i=0; i < this.features.length; i++) {
- this.features[i].destroy();
- }
- OpenLayers.Tile.prototype.destroy.apply(this, arguments);
- },
-
- /**
- */
- draw:function() {
- this.loadFeaturesForRegion(this.requestSuccess);
- },
-
-
- /** get the full request string from the ds and the tile params
- * and call the AJAX loadURL().
- *
- * input are function pointers for what to do on success and failure.
- *
- * @param {function} success
- * @param {function} failure
- */
- loadFeaturesForRegion:function(success, failure) {
-
- if (!this.loaded) {
-
- if (this.url != "") {
-
- // TODO: Hmmm, this stops multiple loads of the data when a
- // result isn't immediately retrieved, but it's hacky.
- // Do it better.
- this.loaded = true;
- OpenLayers.loadURL(this.url, null, this, success, failure);
- }
- }
- },
-
- /** Return from AJAX request
- *
- * @param {} request
- */
- requestSuccess:function(request) {
- var doc = request.responseXML;
-
- if (!doc || request.fileType!="XML") {
- doc = OpenLayers.parseXMLString(request.responseText);
- }
-
- var resultFeatures = doc.getElementsByTagName("featureMember");
-
- //clear old featureList
- this.features = new Array();
-
- for (var i=0; i < resultFeatures.length; i++) {
-
- var feature = new this.layer.featureClass(this.layer,
- resultFeatures[i]);
- this.features.append(feature);
- }
-
- },
-
- /** @final @type String */
- CLASS_NAME: "OpenLayers.Tile.WFS"
- }
-);
-
+++ /dev/null
-/* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
- * See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
- * text of the license. */
-/**
-* @class
-*/
-OpenLayers.Util = new Object();
-
-
-
-
-/**
-* @class This class represents a screen coordinate, in x and y coordinates
-*/
-OpenLayers.Pixel = Class.create();
-OpenLayers.Pixel.prototype = {
-
- /** @type float */
- x: 0.0,
-
- /** @type float */
- y: 0.0,
-
- /**
- * @constructor
- *
- * @param {float} x
- * @param {float} y
- */
- initialize: function(x, y) {
- this.x = x;
- this.y = y;
- },
-
- /**
- * @return string representation of Pixel. ex: "x=200.4,y=242.2"
- * @type str
- */
- toString:function() {
- return ("x=" + this.x + ",y=" + this.y);
- },
-
- /**
- * @type OpenLayers.Pixel
- */
- copyOf:function() {
- return new OpenLayers.Pixel(this.x, this.y);
- },
-
- /**
- * @param {OpenLayers.Pixel} px
- *
- * @return whether or not the point passed in as parameter is equal to this
- * note that if px passed in is null, returns false
- * @type bool
- */
- equals:function(px) {
- var equals = false;
- if (px != null) {
- equals = ((this.x == px.x) && (this.y == px.y));
- }
- return equals;
- },
-
- /**
- * @param {int} x
- * @param {int} y
- *
- * @return a new Pixel with this pixel's x&y augmented by the
- * values passed in.
- * @type OpenLayers.Pixel
- */
- add:function(x, y) {
- return new OpenLayers.Pixel(this.x + x, this.y + y);
- },
-
- /**
- * @param {OpenLayers.Pixel} px
- *
- * @return a new Pixel with this pixel's x&y augmented by the
- * x&y values of the pixel passed in.
- * @type OpenLayers.Pixel
- */
- offset:function(px) {
- return this.add(px.x, px.y);
- },
-
- /** @final @type str */
- CLASS_NAME: "OpenLayers.Pixel"
-};
-
-
-/**
-* @class This class represents a width and height pair
-*/
-OpenLayers.Size = Class.create();
-OpenLayers.Size.prototype = {
-
- /** @type float */
- w: 0.0,
-
- /** @type float */
- h: 0.0,
-
-
- /**
- * @constructor
- *
- * @param {float} w
- * @param {float} h
- */
- initialize: function(w, h) {
- this.w = w;
- this.h = h;
- },
-
- /**
- * @return String representation of OpenLayers.Size object.
- * (ex. <i>"w=55,h=66"</i>)
- * @type String
- */
- toString:function() {
- return ("w=" + this.w + ",h=" + this.h);
- },
-
- /**
- * @return New OpenLayers.Size object with the same w and h values
- * @type OpenLayers.Size
- */
- copyOf:function() {
- return new OpenLayers.Size(this.w, this.h);
- },
-
- /**
- * @param {OpenLayers.Size} sz
- * @returns Boolean value indicating whether the passed-in OpenLayers.Size
- * object has the same w and h components as this
- * note that if sz passed in is null, returns false
- *
- * @type bool
- */
- equals:function(sz) {
- var equals = false;
- if (sz != null) {
- equals = ((this.w == sz.w) && (this.h == sz.h));
- }
- return equals;
- },
-
- /** @final @type String */
- CLASS_NAME: "OpenLayers.Size"
-};
-
-/**
-* @class This class represents a longitude and latitude pair
-*/
-OpenLayers.LonLat = Class.create();
-OpenLayers.LonLat.prototype = {
-
- /** @type float */
- lon: 0.0,
-
- /** @type float */
- lat: 0.0,
-
- /**
- * @constructor
- *
- * @param {float} lon
- * @param {float} lat
- */
- initialize: function(lon, lat) {
- this.lon = lon;
- this.lat = lat;
- },
-
- /**
- * @return String representation of OpenLayers.LonLat object.
- * (ex. <i>"lon=5,lat=42"</i>)
- * @type String
- */
- toString:function() {
- return ("lon=" + this.lon + ",lat=" + this.lat);
- },
-
- /**
- * @return Shortened String representation of OpenLayers.LonLat object.
- * (ex. <i>"5, 42"</i>)
- * @type String
- */
- toShortString:function() {
- return (this.lon + ", " + this.lat);
- },
-
- /**
- * @return New OpenLayers.LonLat object with the same lon and lat values
- * @type OpenLayers.LonLat
- */
- copyOf:function() {
- return new OpenLayers.LonLat(this.lon, this.lat);
- },
-
- /**
- * @param {float} lon
- * @param {float} lat
- *
- * @return A new OpenLayers.LonLat object with the lon and lat passed-in
- * added to this's.
- * @type OpenLayers.LonLat
- */
- add:function(lon, lat) {
- return new OpenLayers.LonLat(this.lon + lon, this.lat + lat);
- },
-
- /**
- * @param {OpenLayers.LonLat} ll
- * @returns Boolean value indicating whether the passed-in OpenLayers.LonLat
- * object has the same lon and lat components as this
- * note that if ll passed in is null, returns false
- *
- * @type bool
- */
- equals:function(ll) {
- var equals = false;
- if (ll != null) {
- equals = ((this.lon == ll.lon) && (this.lat == ll.lat));
- }
- return equals;
- },
-
- /** @final @type String */
- CLASS_NAME: "OpenLayers.LonLat"
-};
-
-/** Alternative constructor that builds a new OpenLayers.LonLat from a
-* parameter string
-*
-* @constructor
-*
-* @param {String} str Comma-separated Lon,Lat coordinate string.
-* (ex. <i>"5,40"</i>)
-*
-* @returns New OpenLayers.LonLat object built from the passed-in String.
-* @type OpenLayers.LonLat
-*/
-OpenLayers.LonLat.fromString = function(str) {
- var pair = str.split(",");
- return new OpenLayers.LonLat(parseFloat(pair[0]),
- parseFloat(pair[1]));
-};
-
-
-
-
-/**
-* @class This class represents a bounding box.
-* Data stored as left, bottom, right, top floats
-*/
-OpenLayers.Bounds = Class.create();
-OpenLayers.Bounds.prototype = {
-
- /** @type float */
- left: 0.0,
-
- /** @type float */
- bottom: 0.0,
-
- /** @type float */
- right: 0.0,
-
- /** @type float */
- top: 0.0,
-
- /**
- * @constructor
- *
- * @param {float} left
- * @param {float} bottom
- * @param {float} right
- * @param {float} top
- *
- */
- initialize: function(left, bottom, right, top) {
- this.left = left;
- this.bottom = bottom;
- this.right = right;
- this.top = top;
- },
-
- /**
- * @returns A fresh copy of the bounds
- * @type OpenLayers.Bounds
- */
- copyOf:function() {
- return new OpenLayers.Bounds(this.left, this.bottom,
- this.right, this.top);
- },
-
- /**
- * @param {OpenLayers.Bounds} bounds
- * @returns Boolean value indicating whether the passed-in OpenLayers.Bounds
- * object has the same left, right, top, bottom components as this
- * note that if bounds passed in is null, returns false
- *
- * @type bool
- */
- equals:function(bounds) {
- var equals = false;
- if (bounds != null) {
- equals = ((this.left == bounds.left) &&
- (this.right == bounds.right) &&
- (this.top == bounds.top) &&
- (this.bottom == bounds.bottom));
- }
- return equals;
- },
-
- /**
- * @return String representation of OpenLayers.Bounds object.
- * (ex.<i>"left-bottom=(5,42) right-top=(10,45)"</i>)
- * @type String
- */
- toString:function(){
- return ( "left-bottom=(" + this.left + "," + this.bottom + ")"
- + " right-top=(" + this.right + "," + this.top + ")" );
- },
-
- /**
- * @return Simple String representation of OpenLayers.Bounds object.
- * (ex. <i>"5,42,10,45"</i>)
- * @type String
- */
- toBBOX:function() {
- return (this.left + "," + this.bottom + ","
- + this.right + "," + this.top);
- },
-
- /**
- * @returns The width of the bounds
- * @type float
- */
- getWidth:function() {
- return (this.right - this.left);
- },
-
- /**
- * @returns The height of the bounds
- * @type float
- */
- getHeight:function() {
- return (this.top - this.bottom);
- },
-
- /**
- * @returns An OpenLayers.Size which represents the size of the box
- * @type OpenLayers.Size
- */
- getSize:function() {
- return new OpenLayers.Size(this.getWidth(), this.getHeight());
- },
-
- /**
- * @returns An OpenLayers.Pixel which represents the center of the bounds
- * @type OpenLayers.Pixel
- */
- getCenterPixel:function() {
- return new OpenLayers.Pixel( (this.left + this.right) / 2,
- (this.bottom + this.top) / 2);
- },
-
- /**
- * @returns An OpenLayers.LonLat which represents the center of the bounds
- * @type OpenLayers.LonLat
- */
- getCenterLonLat:function() {
- return new OpenLayers.LonLat( (this.left + this.right) / 2,
- (this.bottom + this.top) / 2);
- },
-
- /**
- * @param {float} x
- * @param {float} y
- *
- * @returns A new OpenLayers.Bounds whose coordinates are the same as this,
- * but shifted by the passed-in x and y values
- * @type OpenLayers.Bounds
- */
- add:function(x, y){
- return new OpenLayers.Box(this.left + x, this.bottom + y,
- this.right + x, this.top + y);
- },
-
- /**
- * @param {float} x
- * @param {float} y
- * @param {Boolean} inclusive Whether or not to include the border.
- * Default is true
- *
- * @return Whether or not the passed-in coordinates are within this bounds
- * @type Boolean
- */
- contains:function(x, y, inclusive) {
-
- //set default
- if (inclusive == null) {
- inclusive = true;
- }
-
- var contains = false;
- if (inclusive) {
- contains = ((x >= this.left) && (x <= this.right) &&
- (y >= this.bottom) && (y <= this.top));
- } else {
- contains = ((x > this.left) && (x < this.right) &&
- (y > this.bottom) && (y < this.top));
- }
- return contains;
- },
-
- /**
- * @param {OpenLayers.Bounds} bounds
- * @param {Boolean} partial If true, only part of passed-in
- * OpenLayers.Bounds needs be within this bounds.
- * If false, the entire passed-in bounds must be
- * within. Default is false
- * @param {Boolean} inclusive Whether or not to include the border.
- * Default is true
- *
- * @return Whether or not the passed-in OpenLayers.Bounds object is
- * contained within this bounds.
- * @type Boolean
- */
- containsBounds:function(bounds, partial, inclusive) {
-
- //set defaults
- if (partial == null) {
- partial = false;
- }
- if (inclusive == null) {
- inclusive = true;
- }
-
- var inLeft;
- var inTop;
- var inRight;
- var inBottom;
-
- if (inclusive) {
- inLeft = (bounds.left >= this.left) && (bounds.left <= this.right);
- inTop = (bounds.top >= this.bottom) && (bounds.top <= this.top);
- inRight= (bounds.right >= this.left) && (bounds.right <= this.right);
- inBottom = (bounds.bottom >= this.bottom) && (bounds.bottom <= this.top);
- } else {
- inLeft = (bounds.left > this.left) && (bounds.left < this.right);
- inTop = (bounds.top > this.bottom) && (bounds.top < this.top);
- inRight= (bounds.right > this.left) && (bounds.right < this.right);
- inBottom = (bounds.bottom > this.bottom) && (bounds.bottom < this.top);
- }
-
- return (partial) ? (inTop || inBottom) && (inLeft || inRight )
- : (inTop && inLeft && inBottom && inRight);
- },
-
- /**
- * @param {OpenLayers.LonLat} lonlat
- *
- * @returns The quadrant ("br" "tr" "tl" "bl") of the bounds in which
- * the coordinate lies.
- * @type String
- */
- determineQuadrant: function(lonlat) {
-
- var quadrant = "";
- var center = this.getCenterLonLat();
-
- quadrant += (lonlat.lat < center.lat) ? "b" : "t";
- quadrant += (lonlat.lon < center.lon) ? "l" : "r";
-
- return quadrant;
- },
-
- /** @final @type String */
- CLASS_NAME: "OpenLayers.Bounds"
-};
-
-/** Alternative constructor that builds a new OpenLayers.Bounds from a
-* parameter string
-*
-* @constructor
-*
-* @param {String} str Comma-separated bounds string. (ex. <i>"5,42,10,45"</i>)
-*
-* @returns New OpenLayers.Bounds object built from the passed-in String.
-* @type OpenLayers.Bounds
-*/
-OpenLayers.Bounds.fromString = function(str) {
- var bounds = str.split(",");
- return OpenLayers.Bounds.fromArray(bounds);
-};
-
-/** Alternative constructor that builds a new OpenLayers.Bounds
-* from an array
-*
-* @constructor
-*
-* @param {Array} bbox Array of bounds values (ex. <i>[5,42,10,45]</i>)
-*
-* @returns New OpenLayers.Bounds object built from the passed-in Array.
-* @type OpenLayers.Bounds
-*/
-OpenLayers.Bounds.fromArray = function(bbox) {
- return new OpenLayers.Bounds(parseFloat(bbox[0]),
- parseFloat(bbox[1]),
- parseFloat(bbox[2]),
- parseFloat(bbox[3]));
-};
-
-/** Alternative constructor that builds a new OpenLayers.Bounds
-* from an OpenLayers.Size
-*
-* @constructor
-*
-* @param {OpenLayers.Size} size
-*
-* @returns New OpenLayers.Bounds object built with top and left set to 0 and
-* bottom right taken from the passed-in OpenLayers.Size.
-* @type OpenLayers.Bounds
-*/
-OpenLayers.Bounds.fromSize = function(size) {
- return new OpenLayers.Bounds(0,
- size.h,
- size.w,
- 0);
-};
-/**
- * @param {String} quadrant
- *
- * @returns The opposing quadrant ("br" "tr" "tl" "bl"). For Example, if
- * you pass in "bl" it returns "tr", if you pass in "br" it
- * returns "tl", etc.
- * @type String
- */
-OpenLayers.Bounds.oppositeQuadrant = function(quadrant) {
- var opp = "";
-
- opp += (quadrant.charAt(0) == 't') ? 'b' : 't';
- opp += (quadrant.charAt(1) == 'l') ? 'r' : 'l';
-
- return opp;
-};
-
-// Some other helpful things
-
-/**
-* @param {String} sStart
-*
-* @returns Whether or not this string starts with the string passed in.
-* @type Boolean
-*/
-String.prototype.startsWith = function(sStart){
- return (this.substr(0,sStart.length) == sStart);
-};
-
-/**
-* @returns A trimmed version of the string - all leading and
-* trailing spaces removed
-* @type String
-*/
-String.prototype.trim = function() {
-
- var b = 0;
- while(this.substr(b,1) == " ") {
- b++;
- }
-
- var e = this.length - 1;
- while(this.substr(e,1) == " ") {
- e--;
- }
-
- return this.substring(b, e+1);
-};
-
-/** Remove an object from an array. Iterates through the array
-* to find the item, then removes it.
-*
-* @param {Object} item
-*
-* @returns A reference to the array
-* @type Array
-*/
-Array.prototype.remove = function(item) {
- for(var i=0; i < this.length; i++) {
- if(this[i] == item) {
- this.splice(i,1);
- //break;more than once??
- }
- }
- return this;
-}
-
-/**
-* @returns A fresh copy of the array
-* @type Array
-*/
-Array.prototype.copyOf = function() {
- var copy = new Array();
- for (var i = 0; i < this.length; i++) {
- copy[i] = this[i];
- }
- return copy;
-};
-
-/**
-* @param {Object} item
-*/
-Array.prototype.prepend = function(item) {
- this.splice(0, 0, item);
-};
-
-/**
-* @param {Object} item
-*/
-Array.prototype.append = function(item){
- this[this.length] = item;
-};
-
-/**
-*/
-Array.prototype.clear = function() {
- this.length = 0;
-};
-
-/**
-* @param {Object} element
-*
-* @returns The first index of the element in the array if found. Else returns -1
-* @type int
-*/
-Array.prototype.indexOf = function(element) {
- var index = -1;
- for(var i=0; i < this.length; i++) {
- if (this[i] == element) {
- index = i;
- break;
- }
- }
- return index;
-}
-
-/**
- * @param {String} id
- * @param {OpenLayers.Pixel} px
- * @param {OpenLayers.Size} sz
- * @param {String} position
- * @param {String} border
- * @param {String} overflow
- */
-OpenLayers.Util.modifyDOMElement = function(element, id, px, sz, position,
- border, overflow) {
-
- if (id) {
- element.id = id;
- }
- if (px) {
- element.style.left = px.x + "px";
- element.style.top = px.y + "px";
- }
- if (sz) {
- element.style.width = sz.w + "px";
- element.style.height = sz.h + "px";
- }
- if (position) {
- element.style.position = position;
- }
- if (border) {
- element.style.border = border;
- }
- if (overflow) {
- element.style.overflow = overflow;
- }
-};
-
-/**
-* zIndex is NOT set
-*
-* @param {String} id
-* @param {OpenLayers.Pixel} px
-* @param {OpenLayers.Size} sz
-* @param {String} imgURL
-* @param {String} position
-* @param {String} border
-* @param {String} overflow
-*
-* @returns A DOM Div created with the specified attributes.
-* @type DOMElement
-*/
-OpenLayers.Util.createDiv = function(id, px, sz, imgURL, position,
- border, overflow) {
-
- var dom = document.createElement('div');
-
- //set specific properties
- dom.style.padding = "0";
- dom.style.margin = "0";
- if (imgURL) {
- dom.style.backgroundImage = 'url(' + imgURL + ')';
- }
-
- //set generic properties
- if (!id) {
- id = "OpenLayersDiv" + (Math.random() * 10000 % 10000);
- }
- if (!position) {
- position = "absolute";
- }
- OpenLayers.Util.modifyDOMElement(dom, id, px, sz,
- position, border, overflow);
-
- return dom;
-};
-
-/**
-* @param {String} id
-* @param {OpenLayers.Pixel} px
-* @param {OpenLayers.Size} sz
-* @param {String} imgURL
-* @param {String} position
-* @param {String} border
-*
-* @returns A DOM Image created with the specified attributes.
-* @type DOMElement
-*/
-OpenLayers.Util.createImage = function(id, px, sz, imgURL, position, border) {
-
- image = document.createElement("img");
-
- //set special properties
- image.style.alt = id;
- image.galleryImg = "no";
- if (imgURL) {
- image.src = imgURL;
- }
-
- //set generic properties
- if (!id) {
- id = "OpenLayersDiv" + (Math.random() * 10000 % 10000);
- }
- if (!position) {
- position = "relative";
- }
- OpenLayers.Util.modifyDOMElement(image, id, px, sz, position, border);
-
- return image;
-};
-
-OpenLayers.Util.alphaHack = function() {
- var arVersion = navigator.appVersion.split("MSIE");
- var version = parseFloat(arVersion[1]);
-
- return ( (document.body.filters) &&
- (version >= 5.5) && (version < 7) );
-}
-
-/**
-* @param {DOMElement} div Div containing Alpha-adjusted Image
-* @param {String} id
-* @param {OpenLayers.Pixel} px
-* @param {OpenLayers.Size} sz
-* @param {String} imgURL
-* @param {String} position
-* @param {String} border
-* @param {String} sizing 'crop', 'scale', or 'image'. Default is "scale"
-*/
-OpenLayers.Util.modifyAlphaImageDiv = function(div, id, px, sz, imgURL,
- position, border, sizing) {
-
- OpenLayers.Util.modifyDOMElement(div, id, px, sz);
-
- var img = div.childNodes[0];
-
- if (imgURL) {
- img.src = imgURL;
- }
- OpenLayers.Util.modifyDOMElement(img, div.id + "_innerImage", null, sz,
- "relative", border);
-
- if (OpenLayers.Util.alphaHack()) {
- div.style.display = "inline-block";
- if (sizing == null) {
- sizing = "scale";
- }
- div.style.filter = "progid:DXImageTransform.Microsoft" +
- ".AlphaImageLoader(src='" + img.src + "', " +
- "sizingMethod='" + sizing + "')";
- img.style.filter = "progid:DXImageTransform.Microsoft" +
- ".Alpha(opacity=0)";
- }
-};
-
-/**
-* @param {String} id
-* @param {OpenLayers.Pixel} px
-* @param {OpenLayers.Size} sz
-* @param {String} imgURL
-* @param {String} position
-* @param {String} border
-* @param {String} sizing 'crop', 'scale', or 'image'. Default is "scale"
-*
-* @returns A DOM Div created with a DOM Image inside it. If the hack is
-* needed for transparency in IE, it is added.
-* @type DOMElement
-*/
-OpenLayers.Util.createAlphaImageDiv = function(id, px, sz, imgURL,
- position, border, sizing) {
-
- var div = OpenLayers.Util.createDiv();
- var img = OpenLayers.Util.createImage();
- div.appendChild(img);
-
- OpenLayers.Util.modifyAlphaImageDiv(div, id, px, sz, imgURL,
- position, border, sizing);
-
- return div;
-};
-
-
-/** Creates a new hash and copies over all the keys from the
-* passed-in object, but storing them under an uppercased
-* version of the key at which they were stored.
-*
-* @param {Object} object
-*
-* @returns A new Object with all the same keys but uppercased
-* @type Object
-*/
-OpenLayers.Util.upperCaseObject = function (object) {
- var uObject = new Object();
- for (var key in object) {
- uObject[key.toUpperCase()] = object[key];
- }
- return uObject;
-};
-
-/** Takes a hash and copies any keys that don't exist from
-* another hash, by analogy with Object.extend() from
-* Prototype.js.
-*
-* @param {Object} to
-* @param {Object} from
-*
-* @type Object
-*/
-OpenLayers.Util.applyDefaults = function (to, from) {
- for (var key in from) {
- if (to[key] == null) {
- to[key] = from[key];
- }
- }
- return to;
-};
-
-/**
-* @param {Object} params
-*
-* @returns a concatenation of the properties of an object in
-* http parameter notation.
-* (ex. <i>"key1=value1&key2=value2&key3=value3"</i>)
-* @type String
-*/
-OpenLayers.Util.getParameterString = function(params) {
- paramsArray = new Array();
-
- for (var key in params) {
- var value = params[key];
- //skip functions
- if (typeof value == 'function') continue;
-
- paramsArray.push(key + "=" + value);
- }
-
- return paramsArray.join("&");
-};
-
-/**
-* @returns The fully formatted image location string
-* @type String
-*/
-OpenLayers.Util.getImagesLocation = function() {
- return OpenLayers._getScriptLocation() + "img/";
-};
-
-
-
-/** These could/should be made namespace aware?
-*
-* @param {} p
-* @param {str} tagName
-*
-* @return {Array}
-*/
-OpenLayers.Util.getNodes=function(p, tagName) {
- var nodes = Try.these(
- function () {
- return OpenLayers.Util._getNodes(p.documentElement.childNodes,
- tagName);
- },
- function () {
- return OpenLayers.Util._getNodes(p.childNodes, tagName);
- }
- );
- return nodes;
-};
-
-/**
-* @param {Array} nodes
-* @param {str} tagName
-*
-* @return {Array}
-*/
-OpenLayers.Util._getNodes=function(nodes, tagName) {
- var retArray = new Array();
- for (var i=0;i<nodes.length;i++) {
- if (nodes[i].nodeName==tagName) {
- retArray.push(nodes[i]);
- }
- }
-
- return retArray;
-};
-
-
-
-/**
-* @param {} parent
-* @param {str} item
-* @param {int} index
-*
-* @return {str}
-*/
-OpenLayers.Util.getTagText = function (parent, item, index) {
- var result = OpenLayers.Util.getNodes(parent, item);
- if (result && (result.length > 0))
- {
- if (!index) {
- index=0;
- }
- if (result[index].childNodes.length > 1) {
- return result.childNodes[1].nodeValue;
- }
- else if (result[index].childNodes.length == 1) {
- return result[index].firstChild.nodeValue;
- }
- } else {
- return "";
- }
-};
-
-/**
-* @param {Event} evt
-* @param {HTMLDivElement} div
-*
-* @return {boolean}
-*/
-OpenLayers.Util.mouseLeft = function (evt, div) {
- // start with the element to which the mouse has moved
- var target = (evt.relatedTarget) ? evt.relatedTarget : evt.toElement;
- // walk up the DOM tree.
- while (target != div && target != null) {
- target = target.parentNode;
- }
- // if the target we stop at isn't the div, then we've left the div.
- return (target != div);
-};
-
-OpenLayers.Util.rad = function(x) {return x*Math.PI/180;};
-OpenLayers.Util.distVincenty=function(p1, p2) {
- var a = 6378137, b = 6356752.3142, f = 1/298.257223563;
- var L = OpenLayers.Util.rad(p2.lon - p1.lon);
- var U1 = Math.atan((1-f) * Math.tan(OpenLayers.Util.rad(p1.lat)));
- var U2 = Math.atan((1-f) * Math.tan(OpenLayers.Util.rad(p2.lat)));
- var sinU1 = Math.sin(U1), cosU1 = Math.cos(U1);
- var sinU2 = Math.sin(U2), cosU2 = Math.cos(U2);
- var lambda = L, lambdaP = 2*Math.PI;
- var iterLimit = 20;
- while (Math.abs(lambda-lambdaP) > 1e-12 && --iterLimit>0) {
- var sinLambda = Math.sin(lambda), cosLambda = Math.cos(lambda);
- var sinSigma = Math.sqrt((cosU2*sinLambda) * (cosU2*sinLambda) +
- (cosU1*sinU2-sinU1*cosU2*cosLambda) * (cosU1*sinU2-sinU1*cosU2*cosLambda));
- if (sinSigma==0) return 0; // co-incident points
- var cosSigma = sinU1*sinU2 + cosU1*cosU2*cosLambda;
- var sigma = Math.atan2(sinSigma, cosSigma);
- var alpha = Math.asin(cosU1 * cosU2 * sinLambda / sinSigma);
- var cosSqAlpha = Math.cos(alpha) * Math.cos(alpha);
- var cos2SigmaM = cosSigma - 2*sinU1*sinU2/cosSqAlpha;
- var C = f/16*cosSqAlpha*(4+f*(4-3*cosSqAlpha));
- lambdaP = lambda;
- lambda = L + (1-C) * f * Math.sin(alpha) *
- (sigma + C*sinSigma*(cos2SigmaM+C*cosSigma*(-1+2*cos2SigmaM*cos2SigmaM)));
- }
- if (iterLimit==0) return NaN // formula failed to converge
- var uSq = cosSqAlpha * (a*a - b*b) / (b*b);
- var A = 1 + uSq/16384*(4096+uSq*(-768+uSq*(320-175*uSq)));
- var B = uSq/1024 * (256+uSq*(-128+uSq*(74-47*uSq)));
- var deltaSigma = B*sinSigma*(cos2SigmaM+B/4*(cosSigma*(-1+2*cos2SigmaM*cos2SigmaM)-
- B/6*cos2SigmaM*(-3+4*sinSigma*sinSigma)*(-3+4*cos2SigmaM*cos2SigmaM)));
- var s = b*A*(sigma-deltaSigma);
- var d = s.toFixed(3)/1000; // round to 1mm precision
- return d;
-};
+++ /dev/null
-/* Prototype JavaScript framework, version 1.4.0
- * (c) 2005 Sam Stephenson <sam@conio.net>
- *
- * Prototype is freely distributable under the terms of an MIT-style license.
- * For details, see the Prototype web site: http://prototype.conio.net/
- *
-/*--------------------------------------------------------------------------*/
-
-var Prototype = {
- Version: '1.4.0',
- ScriptFragment: '(?:<script.*?>)((\n|\r|.)*?)(?:<\/script>)',
-
- emptyFunction: function() {},
- K: function(x) {return x}
-}
-
-var Class = {
- create: function() {
- return function() {
- this.initialize.apply(this, arguments);
- }
- }
-}
-
-var Abstract = new Object();
-
-Object.extend = function(destination, source) {
- for (property in source) {
- destination[property] = source[property];
- }
- return destination;
-}
-
-Object.inspect = function(object) {
- try {
- if (object == undefined) return 'undefined';
- if (object == null) return 'null';
- return object.inspect ? object.inspect() : object.toString();
- } catch (e) {
- if (e instanceof RangeError) return '...';
- throw e;
- }
-}
-
-Function.prototype.bind = function() {
- var __method = this, args = $A(arguments), object = args.shift();
- return function() {
- return __method.apply(object, args.concat($A(arguments)));
- }
-}
-
-Function.prototype.bindAsEventListener = function(object) {
- var __method = this;
- return function(event) {
- return __method.call(object, event || window.event);
- }
-}
-
-Object.extend(Number.prototype, {
- toColorPart: function() {
- var digits = this.toString(16);
- if (this < 16) return '0' + digits;
- return digits;
- },
-
- succ: function() {
- return this + 1;
- },
-
- times: function(iterator) {
- $R(0, this, true).each(iterator);
- return this;
- }
-});
-
-var Try = {
- these: function() {
- var returnValue;
-
- for (var i = 0; i < arguments.length; i++) {
- var lambda = arguments[i];
- try {
- returnValue = lambda();
- break;
- } catch (e) {}
- }
-
- return returnValue;
- }
-}
-
-/*--------------------------------------------------------------------------*/
-
-var PeriodicalExecuter = Class.create();
-PeriodicalExecuter.prototype = {
- initialize: function(callback, frequency) {
- this.callback = callback;
- this.frequency = frequency;
- this.currentlyExecuting = false;
-
- this.registerCallback();
- },
-
- registerCallback: function() {
- setInterval(this.onTimerEvent.bind(this), this.frequency * 1000);
- },
-
- onTimerEvent: function() {
- if (!this.currentlyExecuting) {
- try {
- this.currentlyExecuting = true;
- this.callback();
- } finally {
- this.currentlyExecuting = false;
- }
- }
- }
-}
-
-/*--------------------------------------------------------------------------*/
-
-function $() {
- var elements = new Array();
-
- for (var i = 0; i < arguments.length; i++) {
- var element = arguments[i];
- if (typeof element == 'string')
- element = document.getElementById(element);
-
- if (arguments.length == 1)
- return element;
-
- elements.push(element);
- }
-
- return elements;
-}
-Object.extend(String.prototype, {
- stripTags: function() {
- return this.replace(/<\/?[^>]+>/gi, '');
- },
-
- stripScripts: function() {
- return this.replace(new RegExp(Prototype.ScriptFragment, 'img'), '');
- },
-
- extractScripts: function() {
- var matchAll = new RegExp(Prototype.ScriptFragment, 'img');
- var matchOne = new RegExp(Prototype.ScriptFragment, 'im');
- return (this.match(matchAll) || []).map(function(scriptTag) {
- return (scriptTag.match(matchOne) || ['', ''])[1];
- });
- },
-
- evalScripts: function() {
- return this.extractScripts().map(eval);
- },
-
- escapeHTML: function() {
- var div = document.createElement('div');
- var text = document.createTextNode(this);
- div.appendChild(text);
- return div.innerHTML;
- },
-
- unescapeHTML: function() {
- var div = document.createElement('div');
- div.innerHTML = this.stripTags();
- return div.childNodes[0] ? div.childNodes[0].nodeValue : '';
- },
-
- toQueryParams: function() {
- var pairs = this.match(/^\??(.*)$/)[1].split('&');
- return pairs.inject({}, function(params, pairString) {
- var pair = pairString.split('=');
- params[pair[0]] = pair[1];
- return params;
- });
- },
-
- toArray: function() {
- return this.split('');
- },
-
- camelize: function() {
- var oStringList = this.split('-');
- if (oStringList.length == 1) return oStringList[0];
-
- var camelizedString = this.indexOf('-') == 0
- ? oStringList[0].charAt(0).toUpperCase() + oStringList[0].substring(1)
- : oStringList[0];
-
- for (var i = 1, len = oStringList.length; i < len; i++) {
- var s = oStringList[i];
- camelizedString += s.charAt(0).toUpperCase() + s.substring(1);
- }
-
- return camelizedString;
- },
-
- inspect: function() {
- return "'" + this.replace('\\', '\\\\').replace("'", '\\\'') + "'";
- }
-});
-
-String.prototype.parseQuery = String.prototype.toQueryParams;
-
-var $break = new Object();
-var $continue = new Object();
-
-var Enumerable = {
- each: function(iterator) {
- var index = 0;
- try {
- this._each(function(value) {
- try {
- iterator(value, index++);
- } catch (e) {
- if (e != $continue) throw e;
- }
- });
- } catch (e) {
- if (e != $break) throw e;
- }
- },
-
- all: function(iterator) {
- var result = true;
- this.each(function(value, index) {
- result = result && !!(iterator || Prototype.K)(value, index);
- if (!result) throw $break;
- });
- return result;
- },
-
- any: function(iterator) {
- var result = true;
- this.each(function(value, index) {
- if (result = !!(iterator || Prototype.K)(value, index))
- throw $break;
- });
- return result;
- },
-
- collect: function(iterator) {
- var results = [];
- this.each(function(value, index) {
- results.push(iterator(value, index));
- });
- return results;
- },
-
- detect: function (iterator) {
- var result;
- this.each(function(value, index) {
- if (iterator(value, index)) {
- result = value;
- throw $break;
- }
- });
- return result;
- },
-
- findAll: function(iterator) {
- var results = [];
- this.each(function(value, index) {
- if (iterator(value, index))
- results.push(value);
- });
- return results;
- },
-
- grep: function(pattern, iterator) {
- var results = [];
- this.each(function(value, index) {
- var stringValue = value.toString();
- if (stringValue.match(pattern))
- results.push((iterator || Prototype.K)(value, index));
- })
- return results;
- },
-
- include: function(object) {
- var found = false;
- this.each(function(value) {
- if (value == object) {
- found = true;
- throw $break;
- }
- });
- return found;
- },
-
- inject: function(memo, iterator) {
- this.each(function(value, index) {
- memo = iterator(memo, value, index);
- });
- return memo;
- },
-
- invoke: function(method) {
- var args = $A(arguments).slice(1);
- return this.collect(function(value) {
- return value[method].apply(value, args);
- });
- },
-
- max: function(iterator) {
- var result;
- this.each(function(value, index) {
- value = (iterator || Prototype.K)(value, index);
- if (value >= (result || value))
- result = value;
- });
- return result;
- },
-
- min: function(iterator) {
- var result;
- this.each(function(value, index) {
- value = (iterator || Prototype.K)(value, index);
- if (value <= (result || value))
- result = value;
- });
- return result;
- },
-
- partition: function(iterator) {
- var trues = [], falses = [];
- this.each(function(value, index) {
- ((iterator || Prototype.K)(value, index) ?
- trues : falses).push(value);
- });
- return [trues, falses];
- },
-
- pluck: function(property) {
- var results = [];
- this.each(function(value, index) {
- results.push(value[property]);
- });
- return results;
- },
-
- reject: function(iterator) {
- var results = [];
- this.each(function(value, index) {
- if (!iterator(value, index))
- results.push(value);
- });
- return results;
- },
-
- sortBy: function(iterator) {
- return this.collect(function(value, index) {
- return {value: value, criteria: iterator(value, index)};
- }).sort(function(left, right) {
- var a = left.criteria, b = right.criteria;
- return a < b ? -1 : a > b ? 1 : 0;
- }).pluck('value');
- },
-
- toArray: function() {
- return this.collect(Prototype.K);
- },
-
- zip: function() {
- var iterator = Prototype.K, args = $A(arguments);
- if (typeof args.last() == 'function')
- iterator = args.pop();
-
- var collections = [this].concat(args).map($A);
- return this.map(function(value, index) {
- iterator(value = collections.pluck(index));
- return value;
- });
- },
-
- inspect: function() {
- return '#<Enumerable:' + this.toArray().inspect() + '>';
- }
-}
-
-Object.extend(Enumerable, {
- map: Enumerable.collect,
- find: Enumerable.detect,
- select: Enumerable.findAll,
- member: Enumerable.include,
- entries: Enumerable.toArray
-});
-var $A = Array.from = function(iterable) {
- if (!iterable) return [];
- if (iterable.toArray) {
- return iterable.toArray();
- } else {
- var results = [];
- for (var i = 0; i < iterable.length; i++)
- results.push(iterable[i]);
- return results;
- }
-}
-
-Object.extend(Array.prototype, Enumerable);
-
-Array.prototype._reverse = Array.prototype.reverse;
-
-Object.extend(Array.prototype, {
- _each: function(iterator) {
- for (var i = 0; i < this.length; i++)
- iterator(this[i]);
- },
-
- clear: function() {
- this.length = 0;
- return this;
- },
-
- first: function() {
- return this[0];
- },
-
- last: function() {
- return this[this.length - 1];
- },
-
- compact: function() {
- return this.select(function(value) {
- return value != undefined || value != null;
- });
- },
-
- flatten: function() {
- return this.inject([], function(array, value) {
- return array.concat(value.constructor == Array ?
- value.flatten() : [value]);
- });
- },
-
- without: function() {
- var values = $A(arguments);
- return this.select(function(value) {
- return !values.include(value);
- });
- },
-
- indexOf: function(object) {
- for (var i = 0; i < this.length; i++)
- if (this[i] == object) return i;
- return -1;
- },
-
- reverse: function(inline) {
- return (inline !== false ? this : this.toArray())._reverse();
- },
-
- shift: function() {
- var result = this[0];
- for (var i = 0; i < this.length - 1; i++)
- this[i] = this[i + 1];
- this.length--;
- return result;
- },
-
- inspect: function() {
- return '[' + this.map(Object.inspect).join(', ') + ']';
- }
-});
-var Hash = {
- _each: function(iterator) {
- for (key in this) {
- var value = this[key];
- if (typeof value == 'function') continue;
-
- var pair = [key, value];
- pair.key = key;
- pair.value = value;
- iterator(pair);
- }
- },
-
- keys: function() {
- return this.pluck('key');
- },
-
- values: function() {
- return this.pluck('value');
- },
-
- merge: function(hash) {
- return $H(hash).inject($H(this), function(mergedHash, pair) {
- mergedHash[pair.key] = pair.value;
- return mergedHash;
- });
- },
-
- toQueryString: function() {
- return this.map(function(pair) {
- return pair.map(encodeURIComponent).join('=');
- }).join('&');
- },
-
- inspect: function() {
- return '#<Hash:{' + this.map(function(pair) {
- return pair.map(Object.inspect).join(': ');
- }).join(', ') + '}>';
- }
-}
-
-function $H(object) {
- var hash = Object.extend({}, object || {});
- Object.extend(hash, Enumerable);
- Object.extend(hash, Hash);
- return hash;
-}
-ObjectRange = Class.create();
-Object.extend(ObjectRange.prototype, Enumerable);
-Object.extend(ObjectRange.prototype, {
- initialize: function(start, end, exclusive) {
- this.start = start;
- this.end = end;
- this.exclusive = exclusive;
- },
-
- _each: function(iterator) {
- var value = this.start;
- do {
- iterator(value);
- value = value.succ();
- } while (this.include(value));
- },
-
- include: function(value) {
- if (value < this.start)
- return false;
- if (this.exclusive)
- return value < this.end;
- return value <= this.end;
- }
-});
-
-var $R = function(start, end, exclusive) {
- return new ObjectRange(start, end, exclusive);
-}
-
-var Ajax = {
- getTransport: function() {
- return Try.these(
- function() {return new ActiveXObject('Msxml2.XMLHTTP')},
- function() {return new ActiveXObject('Microsoft.XMLHTTP')},
- function() {return new XMLHttpRequest()}
- ) || false;
- },
-
- activeRequestCount: 0
-}
-
-Ajax.Responders = {
- responders: [],
-
- _each: function(iterator) {
- this.responders._each(iterator);
- },
-
- register: function(responderToAdd) {
- if (!this.include(responderToAdd))
- this.responders.push(responderToAdd);
- },
-
- unregister: function(responderToRemove) {
- this.responders = this.responders.without(responderToRemove);
- },
-
- dispatch: function(callback, request, transport, json) {
- this.each(function(responder) {
- if (responder[callback] && typeof responder[callback] == 'function') {
- try {
- responder[callback].apply(responder, [request, transport, json]);
- } catch (e) {}
- }
- });
- }
-};
-
-Object.extend(Ajax.Responders, Enumerable);
-
-Ajax.Responders.register({
- onCreate: function() {
- Ajax.activeRequestCount++;
- },
-
- onComplete: function() {
- Ajax.activeRequestCount--;
- }
-});
-
-Ajax.Base = function() {};
-Ajax.Base.prototype = {
- setOptions: function(options) {
- this.options = {
- method: 'post',
- asynchronous: true,
- parameters: ''
- }
- Object.extend(this.options, options || {});
- },
-
- responseIsSuccess: function() {
- return this.transport.status == undefined
- || this.transport.status == 0
- || (this.transport.status >= 200 && this.transport.status < 300);
- },
-
- responseIsFailure: function() {
- return !this.responseIsSuccess();
- }
-}
-
-Ajax.Request = Class.create();
-Ajax.Request.Events =
- ['Uninitialized', 'Loading', 'Loaded', 'Interactive', 'Complete'];
-
-Ajax.Request.prototype = Object.extend(new Ajax.Base(), {
- initialize: function(url, options) {
- this.transport = Ajax.getTransport();
- this.setOptions(options);
- this.request(url);
- },
-
- request: function(url) {
- var parameters = this.options.parameters || '';
- if (parameters.length > 0) parameters += '&_=';
-
- try {
- this.url = url;
- if (this.options.method == 'get' && parameters.length > 0)
- this.url += (this.url.match(/\?/) ? '&' : '?') + parameters;
-
- Ajax.Responders.dispatch('onCreate', this, this.transport);
-
- this.transport.open(this.options.method, this.url,
- this.options.asynchronous);
-
- if (this.options.asynchronous) {
- this.transport.onreadystatechange = this.onStateChange.bind(this);
- setTimeout((function() {this.respondToReadyState(1)}).bind(this), 10);
- }
-
- this.setRequestHeaders();
-
- var body = this.options.postBody ? this.options.postBody : parameters;
- this.transport.send(this.options.method == 'post' ? body : null);
-
- } catch (e) {
- this.dispatchException(e);
- }
- },
-
- setRequestHeaders: function() {
- var requestHeaders =
- ['X-Requested-With', 'XMLHttpRequest',
- 'X-Prototype-Version', Prototype.Version];
-
- if (this.options.method == 'post') {
- requestHeaders.push('Content-type',
- 'application/x-www-form-urlencoded');
-
- /* Force "Connection: close" for Mozilla browsers to work around
- * a bug where XMLHttpReqeuest sends an incorrect Content-length
- * header. See Mozilla Bugzilla #246651.
- */
- if (this.transport.overrideMimeType)
- requestHeaders.push('Connection', 'close');
- }
-
- if (this.options.requestHeaders)
- requestHeaders.push.apply(requestHeaders, this.options.requestHeaders);
-
- for (var i = 0; i < requestHeaders.length; i += 2)
- this.transport.setRequestHeader(requestHeaders[i], requestHeaders[i+1]);
- },
-
- onStateChange: function() {
- var readyState = this.transport.readyState;
- if (readyState != 1)
- this.respondToReadyState(this.transport.readyState);
- },
-
- header: function(name) {
- try {
- return this.transport.getResponseHeader(name);
- } catch (e) {}
- },
-
- evalJSON: function() {
- try {
- return eval(this.header('X-JSON'));
- } catch (e) {}
- },
-
- evalResponse: function() {
- try {
- return eval(this.transport.responseText);
- } catch (e) {
- this.dispatchException(e);
- }
- },
-
- respondToReadyState: function(readyState) {
- var event = Ajax.Request.Events[readyState];
- var transport = this.transport, json = this.evalJSON();
-
- if (event == 'Complete') {
- try {
- (this.options['on' + this.transport.status]
- || this.options['on' + (this.responseIsSuccess() ? 'Success' : 'Failure')]
- || Prototype.emptyFunction)(transport, json);
- } catch (e) {
- this.dispatchException(e);
- }
-
- if ((this.header('Content-type') || '').match(/^text\/javascript/i))
- this.evalResponse();
- }
-
- try {
- (this.options['on' + event] || Prototype.emptyFunction)(transport, json);
- Ajax.Responders.dispatch('on' + event, this, transport, json);
- } catch (e) {
- this.dispatchException(e);
- }
-
- /* Avoid memory leak in MSIE: clean up the oncomplete event handler */
- if (event == 'Complete')
- this.transport.onreadystatechange = Prototype.emptyFunction;
- },
-
- dispatchException: function(exception) {
- (this.options.onException || Prototype.emptyFunction)(this, exception);
- Ajax.Responders.dispatch('onException', this, exception);
- }
-});
-
-Ajax.Updater = Class.create();
-
-Object.extend(Object.extend(Ajax.Updater.prototype, Ajax.Request.prototype), {
- initialize: function(container, url, options) {
- this.containers = {
- success: container.success ? $(container.success) : $(container),
- failure: container.failure ? $(container.failure) :
- (container.success ? null : $(container))
- }
-
- this.transport = Ajax.getTransport();
- this.setOptions(options);
-
- var onComplete = this.options.onComplete || Prototype.emptyFunction;
- this.options.onComplete = (function(transport, object) {
- this.updateContent();
- onComplete(transport, object);
- }).bind(this);
-
- this.request(url);
- },
-
- updateContent: function() {
- var receiver = this.responseIsSuccess() ?
- this.containers.success : this.containers.failure;
- var response = this.transport.responseText;
-
- if (!this.options.evalScripts)
- response = response.stripScripts();
-
- if (receiver) {
- if (this.options.insertion) {
- new this.options.insertion(receiver, response);
- } else {
- Element.update(receiver, response);
- }
- }
-
- if (this.responseIsSuccess()) {
- if (this.onComplete)
- setTimeout(this.onComplete.bind(this), 10);
- }
- }
-});
-
-Ajax.PeriodicalUpdater = Class.create();
-Ajax.PeriodicalUpdater.prototype = Object.extend(new Ajax.Base(), {
- initialize: function(container, url, options) {
- this.setOptions(options);
- this.onComplete = this.options.onComplete;
-
- this.frequency = (this.options.frequency || 2);
- this.decay = (this.options.decay || 1);
-
- this.updater = {};
- this.container = container;
- this.url = url;
-
- this.start();
- },
-
- start: function() {
- this.options.onComplete = this.updateComplete.bind(this);
- this.onTimerEvent();
- },
-
- stop: function() {
- this.updater.onComplete = undefined;
- clearTimeout(this.timer);
- (this.onComplete || Prototype.emptyFunction).apply(this, arguments);
- },
-
- updateComplete: function(request) {
- if (this.options.decay) {
- this.decay = (request.responseText == this.lastText ?
- this.decay * this.options.decay : 1);
-
- this.lastText = request.responseText;
- }
- this.timer = setTimeout(this.onTimerEvent.bind(this),
- this.decay * this.frequency * 1000);
- },
-
- onTimerEvent: function() {
- this.updater = new Ajax.Updater(this.container, this.url, this.options);
- }
-});
-document.getElementsByClassName = function(className, parentElement) {
- var children = ($(parentElement) || document.body).getElementsByTagName('*');
- return $A(children).inject([], function(elements, child) {
- if (child.className.match(new RegExp("(^|\\s)" + className + "(\\s|$)")))
- elements.push(child);
- return elements;
- });
-}
-
-/*--------------------------------------------------------------------------*/
-
-if (!window.Element) {
- var Element = new Object();
-}
-
-Object.extend(Element, {
- visible: function(element) {
- return $(element).style.display != 'none';
- },
-
- toggle: function() {
- for (var i = 0; i < arguments.length; i++) {
- var element = $(arguments[i]);
- Element[Element.visible(element) ? 'hide' : 'show'](element);
- }
- },
-
- hide: function() {
- for (var i = 0; i < arguments.length; i++) {
- var element = $(arguments[i]);
- element.style.display = 'none';
- }
- },
-
- show: function() {
- for (var i = 0; i < arguments.length; i++) {
- var element = $(arguments[i]);
- element.style.display = '';
- }
- },
-
- remove: function(element) {
- element = $(element);
- element.parentNode.removeChild(element);
- },
-
- update: function(element, html) {
- $(element).innerHTML = html.stripScripts();
- setTimeout(function() {html.evalScripts()}, 10);
- },
-
- getHeight: function(element) {
- element = $(element);
- return element.offsetHeight;
- },
-
- classNames: function(element) {
- return new Element.ClassNames(element);
- },
-
- hasClassName: function(element, className) {
- if (!(element = $(element))) return;
- return Element.classNames(element).include(className);
- },
-
- addClassName: function(element, className) {
- if (!(element = $(element))) return;
- return Element.classNames(element).add(className);
- },
-
- removeClassName: function(element, className) {
- if (!(element = $(element))) return;
- return Element.classNames(element).remove(className);
- },
-
- // removes whitespace-only text node children
- cleanWhitespace: function(element) {
- element = $(element);
- for (var i = 0; i < element.childNodes.length; i++) {
- var node = element.childNodes[i];
- if (node.nodeType == 3 && !/\S/.test(node.nodeValue))
- Element.remove(node);
- }
- },
-
- empty: function(element) {
- return $(element).innerHTML.match(/^\s*$/);
- },
-
- scrollTo: function(element) {
- element = $(element);
- var x = element.x ? element.x : element.offsetLeft,
- y = element.y ? element.y : element.offsetTop;
- window.scrollTo(x, y);
- },
-
- getStyle: function(element, style) {
- element = $(element);
- var value = element.style[style.camelize()];
- if (!value) {
- if (document.defaultView && document.defaultView.getComputedStyle) {
- var css = document.defaultView.getComputedStyle(element, null);
- value = css ? css.getPropertyValue(style) : null;
- } else if (element.currentStyle) {
- value = element.currentStyle[style.camelize()];
- }
- }
-
- if (window.opera && ['left', 'top', 'right', 'bottom'].include(style))
- if (Element.getStyle(element, 'position') == 'static') value = 'auto';
-
- return value == 'auto' ? null : value;
- },
-
- setStyle: function(element, style) {
- element = $(element);
- for (name in style)
- element.style[name.camelize()] = style[name];
- },
-
- getDimensions: function(element) {
- element = $(element);
- if (Element.getStyle(element, 'display') != 'none')
- return {width: element.offsetWidth, height: element.offsetHeight};
-
- // All *Width and *Height properties give 0 on elements with display none,
- // so enable the element temporarily
- var els = element.style;
- var originalVisibility = els.visibility;
- var originalPosition = els.position;
- els.visibility = 'hidden';
- els.position = 'absolute';
- els.display = '';
- var originalWidth = element.clientWidth;
- var originalHeight = element.clientHeight;
- els.display = 'none';
- els.position = originalPosition;
- els.visibility = originalVisibility;
- return {width: originalWidth, height: originalHeight};
- },
-
- makePositioned: function(element) {
- element = $(element);
- var pos = Element.getStyle(element, 'position');
- if (pos == 'static' || !pos) {
- element._madePositioned = true;
- element.style.position = 'relative';
- // Opera returns the offset relative to the positioning context, when an
- // element is position relative but top and left have not been defined
- if (window.opera) {
- element.style.top = 0;
- element.style.left = 0;
- }
- }
- },
-
- undoPositioned: function(element) {
- element = $(element);
- if (element._madePositioned) {
- element._madePositioned = undefined;
- element.style.position =
- element.style.top =
- element.style.left =
- element.style.bottom =
- element.style.right = '';
- }
- },
-
- makeClipping: function(element) {
- element = $(element);
- if (element._overflow) return;
- element._overflow = element.style.overflow;
- if ((Element.getStyle(element, 'overflow') || 'visible') != 'hidden')
- element.style.overflow = 'hidden';
- },
-
- undoClipping: function(element) {
- element = $(element);
- if (element._overflow) return;
- element.style.overflow = element._overflow;
- element._overflow = undefined;
- }
-});
-
-var Toggle = new Object();
-Toggle.display = Element.toggle;
-
-/*--------------------------------------------------------------------------*/
-
-Abstract.Insertion = function(adjacency) {
- this.adjacency = adjacency;
-}
-
-Abstract.Insertion.prototype = {
- initialize: function(element, content) {
- this.element = $(element);
- this.content = content.stripScripts();
-
- if (this.adjacency && this.element.insertAdjacentHTML) {
- try {
- this.element.insertAdjacentHTML(this.adjacency, this.content);
- } catch (e) {
- if (this.element.tagName.toLowerCase() == 'tbody') {
- this.insertContent(this.contentFromAnonymousTable());
- } else {
- throw e;
- }
- }
- } else {
- this.range = this.element.ownerDocument.createRange();
- if (this.initializeRange) this.initializeRange();
- this.insertContent([this.range.createContextualFragment(this.content)]);
- }
-
- setTimeout(function() {content.evalScripts()}, 10);
- },
-
- contentFromAnonymousTable: function() {
- var div = document.createElement('div');
- div.innerHTML = '<table><tbody>' + this.content + '</tbody></table>';
- return $A(div.childNodes[0].childNodes[0].childNodes);
- }
-}
-
-var Insertion = new Object();
-
-Insertion.Before = Class.create();
-Insertion.Before.prototype = Object.extend(new Abstract.Insertion('beforeBegin'), {
- initializeRange: function() {
- this.range.setStartBefore(this.element);
- },
-
- insertContent: function(fragments) {
- fragments.each((function(fragment) {
- this.element.parentNode.insertBefore(fragment, this.element);
- }).bind(this));
- }
-});
-
-Insertion.Top = Class.create();
-Insertion.Top.prototype = Object.extend(new Abstract.Insertion('afterBegin'), {
- initializeRange: function() {
- this.range.selectNodeContents(this.element);
- this.range.collapse(true);
- },
-
- insertContent: function(fragments) {
- fragments.reverse(false).each((function(fragment) {
- this.element.insertBefore(fragment, this.element.firstChild);
- }).bind(this));
- }
-});
-
-Insertion.Bottom = Class.create();
-Insertion.Bottom.prototype = Object.extend(new Abstract.Insertion('beforeEnd'), {
- initializeRange: function() {
- this.range.selectNodeContents(this.element);
- this.range.collapse(this.element);
- },
-
- insertContent: function(fragments) {
- fragments.each((function(fragment) {
- this.element.appendChild(fragment);
- }).bind(this));
- }
-});
-
-Insertion.After = Class.create();
-Insertion.After.prototype = Object.extend(new Abstract.Insertion('afterEnd'), {
- initializeRange: function() {
- this.range.setStartAfter(this.element);
- },
-
- insertContent: function(fragments) {
- fragments.each((function(fragment) {
- this.element.parentNode.insertBefore(fragment,
- this.element.nextSibling);
- }).bind(this));
- }
-});
-
-/*--------------------------------------------------------------------------*/
-
-Element.ClassNames = Class.create();
-Element.ClassNames.prototype = {
- initialize: function(element) {
- this.element = $(element);
- },
-
- _each: function(iterator) {
- this.element.className.split(/\s+/).select(function(name) {
- return name.length > 0;
- })._each(iterator);
- },
-
- set: function(className) {
- this.element.className = className;
- },
-
- add: function(classNameToAdd) {
- if (this.include(classNameToAdd)) return;
- this.set(this.toArray().concat(classNameToAdd).join(' '));
- },
-
- remove: function(classNameToRemove) {
- if (!this.include(classNameToRemove)) return;
- this.set(this.select(function(className) {
- return className != classNameToRemove;
- }).join(' '));
- },
-
- toString: function() {
- return this.toArray().join(' ');
- }
-}
-
-Object.extend(Element.ClassNames.prototype, Enumerable);
-var Field = {
- clear: function() {
- for (var i = 0; i < arguments.length; i++)
- $(arguments[i]).value = '';
- },
-
- focus: function(element) {
- $(element).focus();
- },
-
- present: function() {
- for (var i = 0; i < arguments.length; i++)
- if ($(arguments[i]).value == '') return false;
- return true;
- },
-
- select: function(element) {
- $(element).select();
- },
-
- activate: function(element) {
- element = $(element);
- element.focus();
- if (element.select)
- element.select();
- }
-}
-
-/*--------------------------------------------------------------------------*/
-
-var Form = {
- serialize: function(form) {
- var elements = Form.getElements($(form));
- var queryComponents = new Array();
-
- for (var i = 0; i < elements.length; i++) {
- var queryComponent = Form.Element.serialize(elements[i]);
- if (queryComponent)
- queryComponents.push(queryComponent);
- }
-
- return queryComponents.join('&');
- },
-
- getElements: function(form) {
- form = $(form);
- var elements = new Array();
-
- for (tagName in Form.Element.Serializers) {
- var tagElements = form.getElementsByTagName(tagName);
- for (var j = 0; j < tagElements.length; j++)
- elements.push(tagElements[j]);
- }
- return elements;
- },
-
- getInputs: function(form, typeName, name) {
- form = $(form);
- var inputs = form.getElementsByTagName('input');
-
- if (!typeName && !name)
- return inputs;
-
- var matchingInputs = new Array();
- for (var i = 0; i < inputs.length; i++) {
- var input = inputs[i];
- if ((typeName && input.type != typeName) ||
- (name && input.name != name))
- continue;
- matchingInputs.push(input);
- }
-
- return matchingInputs;
- },
-
- disable: function(form) {
- var elements = Form.getElements(form);
- for (var i = 0; i < elements.length; i++) {
- var element = elements[i];
- element.blur();
- element.disabled = 'true';
- }
- },
-
- enable: function(form) {
- var elements = Form.getElements(form);
- for (var i = 0; i < elements.length; i++) {
- var element = elements[i];
- element.disabled = '';
- }
- },
-
- findFirstElement: function(form) {
- return Form.getElements(form).find(function(element) {
- return element.type != 'hidden' && !element.disabled &&
- ['input', 'select', 'textarea'].include(element.tagName.toLowerCase());
- });
- },
-
- focusFirstElement: function(form) {
- Field.activate(Form.findFirstElement(form));
- },
-
- reset: function(form) {
- $(form).reset();
- }
-}
-
-Form.Element = {
- serialize: function(element) {
- element = $(element);
- var method = element.tagName.toLowerCase();
- var parameter = Form.Element.Serializers[method](element);
-
- if (parameter) {
- var key = encodeURIComponent(parameter[0]);
- if (key.length == 0) return;
-
- if (parameter[1].constructor != Array)
- parameter[1] = [parameter[1]];
-
- return parameter[1].map(function(value) {
- return key + '=' + encodeURIComponent(value);
- }).join('&');
- }
- },
-
- getValue: function(element) {
- element = $(element);
- var method = element.tagName.toLowerCase();
- var parameter = Form.Element.Serializers[method](element);
-
- if (parameter)
- return parameter[1];
- }
-}
-
-Form.Element.Serializers = {
- input: function(element) {
- switch (element.type.toLowerCase()) {
- case 'submit':
- case 'hidden':
- case 'password':
- case 'text':
- return Form.Element.Serializers.textarea(element);
- case 'checkbox':
- case 'radio':
- return Form.Element.Serializers.inputSelector(element);
- }
- return false;
- },
-
- inputSelector: function(element) {
- if (element.checked)
- return [element.name, element.value];
- },
-
- textarea: function(element) {
- return [element.name, element.value];
- },
-
- select: function(element) {
- return Form.Element.Serializers[element.type == 'select-one' ?
- 'selectOne' : 'selectMany'](element);
- },
-
- selectOne: function(element) {
- var value = '', opt, index = element.selectedIndex;
- if (index >= 0) {
- opt = element.options[index];
- value = opt.value;
- if (!value && !('value' in opt))
- value = opt.text;
- }
- return [element.name, value];
- },
-
- selectMany: function(element) {
- var value = new Array();
- for (var i = 0; i < element.length; i++) {
- var opt = element.options[i];
- if (opt.selected) {
- var optValue = opt.value;
- if (!optValue && !('value' in opt))
- optValue = opt.text;
- value.push(optValue);
- }
- }
- return [element.name, value];
- }
-}
-
-/*--------------------------------------------------------------------------*/
-
-var $F = Form.Element.getValue;
-
-/*--------------------------------------------------------------------------*/
-
-Abstract.TimedObserver = function() {}
-Abstract.TimedObserver.prototype = {
- initialize: function(element, frequency, callback) {
- this.frequency = frequency;
- this.element = $(element);
- this.callback = callback;
-
- this.lastValue = this.getValue();
- this.registerCallback();
- },
-
- registerCallback: function() {
- setInterval(this.onTimerEvent.bind(this), this.frequency * 1000);
- },
-
- onTimerEvent: function() {
- var value = this.getValue();
- if (this.lastValue != value) {
- this.callback(this.element, value);
- this.lastValue = value;
- }
- }
-}
-
-Form.Element.Observer = Class.create();
-Form.Element.Observer.prototype = Object.extend(new Abstract.TimedObserver(), {
- getValue: function() {
- return Form.Element.getValue(this.element);
- }
-});
-
-Form.Observer = Class.create();
-Form.Observer.prototype = Object.extend(new Abstract.TimedObserver(), {
- getValue: function() {
- return Form.serialize(this.element);
- }
-});
-
-/*--------------------------------------------------------------------------*/
-
-Abstract.EventObserver = function() {}
-Abstract.EventObserver.prototype = {
- initialize: function(element, callback) {
- this.element = $(element);
- this.callback = callback;
-
- this.lastValue = this.getValue();
- if (this.element.tagName.toLowerCase() == 'form')
- this.registerFormCallbacks();
- else
- this.registerCallback(this.element);
- },
-
- onElementEvent: function() {
- var value = this.getValue();
- if (this.lastValue != value) {
- this.callback(this.element, value);
- this.lastValue = value;
- }
- },
-
- registerFormCallbacks: function() {
- var elements = Form.getElements(this.element);
- for (var i = 0; i < elements.length; i++)
- this.registerCallback(elements[i]);
- },
-
- registerCallback: function(element) {
- if (element.type) {
- switch (element.type.toLowerCase()) {
- case 'checkbox':
- case 'radio':
- Event.observe(element, 'click', this.onElementEvent.bind(this));
- break;
- case 'password':
- case 'text':
- case 'textarea':
- case 'select-one':
- case 'select-multiple':
- Event.observe(element, 'change', this.onElementEvent.bind(this));
- break;
- }
- }
- }
-}
-
-Form.Element.EventObserver = Class.create();
-Form.Element.EventObserver.prototype = Object.extend(new Abstract.EventObserver(), {
- getValue: function() {
- return Form.Element.getValue(this.element);
- }
-});
-
-Form.EventObserver = Class.create();
-Form.EventObserver.prototype = Object.extend(new Abstract.EventObserver(), {
- getValue: function() {
- return Form.serialize(this.element);
- }
-});
-if (!window.Event) {
- var Event = new Object();
-}
-
-Object.extend(Event, {
- KEY_BACKSPACE: 8,
- KEY_TAB: 9,
- KEY_RETURN: 13,
- KEY_ESC: 27,
- KEY_LEFT: 37,
- KEY_UP: 38,
- KEY_RIGHT: 39,
- KEY_DOWN: 40,
- KEY_DELETE: 46,
-
- element: function(event) {
- return event.target || event.srcElement;
- },
-
- isLeftClick: function(event) {
- return (((event.which) && (event.which == 1)) ||
- ((event.button) && (event.button == 1)));
- },
-
- pointerX: function(event) {
- return event.pageX || (event.clientX +
- (document.documentElement.scrollLeft || document.body.scrollLeft));
- },
-
- pointerY: function(event) {
- return event.pageY || (event.clientY +
- (document.documentElement.scrollTop || document.body.scrollTop));
- },
-
- stop: function(event) {
- if (event.preventDefault) {
- event.preventDefault();
- event.stopPropagation();
- } else {
- event.returnValue = false;
- event.cancelBubble = true;
- }
- },
-
- // find the first node with the given tagName, starting from the
- // node the event was triggered on; traverses the DOM upwards
- findElement: function(event, tagName) {
- var element = Event.element(event);
- while (element.parentNode && (!element.tagName ||
- (element.tagName.toUpperCase() != tagName.toUpperCase())))
- element = element.parentNode;
- return element;
- },
-
- observers: false,
-
- _observeAndCache: function(element, name, observer, useCapture) {
- if (!this.observers) this.observers = [];
- if (element.addEventListener) {
- this.observers.push([element, name, observer, useCapture]);
- element.addEventListener(name, observer, useCapture);
- } else if (element.attachEvent) {
- this.observers.push([element, name, observer, useCapture]);
- element.attachEvent('on' + name, observer);
- }
- },
-
- unloadCache: function() {
- if (!Event.observers) return;
- for (var i = 0; i < Event.observers.length; i++) {
- Event.stopObserving.apply(this, Event.observers[i]);
- Event.observers[i][0] = null;
- }
- Event.observers = false;
- },
-
- observe: function(elementParam, name, observer, useCapture) {
- var element = $(elementParam);
- useCapture = useCapture || false;
-
- if (name == 'keypress' &&
- (navigator.appVersion.match(/Konqueror|Safari|KHTML/)
- || element.attachEvent))
- name = 'keydown';
-
- this._observeAndCache(element, name, observer, useCapture);
- },
-
- stopObserving: function(elementParam, name, observer, useCapture) {
- var element = $(elementParam);
- useCapture = useCapture || false;
-
- if (name == 'keypress' &&
- (navigator.appVersion.match(/Konqueror|Safari|KHTML/)
- || element.detachEvent))
- name = 'keydown';
-
- if (element.removeEventListener) {
- element.removeEventListener(name, observer, useCapture);
- } else if (element.detachEvent) {
- element.detachEvent('on' + name, observer);
- }
- }
-});
-
-/* prevent memory leaks in IE */
-Event.observe(window, 'unload', Event.unloadCache, false);
-var Position = {
- // set to true if needed, warning: firefox performance problems
- // NOT neeeded for page scrolling, only if draggable contained in
- // scrollable elements
- includeScrollOffsets: false,
-
- // must be called before calling withinIncludingScrolloffset, every time the
- // page is scrolled
- prepare: function() {
- this.deltaX = window.pageXOffset
- || document.documentElement.scrollLeft
- || document.body.scrollLeft
- || 0;
- this.deltaY = window.pageYOffset
- || document.documentElement.scrollTop
- || document.body.scrollTop
- || 0;
- },
-
- realOffset: function(element) {
- var valueT = 0, valueL = 0;
- do {
- valueT += element.scrollTop || 0;
- valueL += element.scrollLeft || 0;
- element = element.parentNode;
- } while (element);
- return [valueL, valueT];
- },
-
- cumulativeOffset: function(element) {
- var valueT = 0, valueL = 0;
- do {
- valueT += element.offsetTop || 0;
- valueL += element.offsetLeft || 0;
- element = element.offsetParent;
- } while (element);
- return [valueL, valueT];
- },
-
- positionedOffset: function(element) {
- var valueT = 0, valueL = 0;
- do {
- valueT += element.offsetTop || 0;
- valueL += element.offsetLeft || 0;
- element = element.offsetParent;
- if (element) {
- p = Element.getStyle(element, 'position');
- if (p == 'relative' || p == 'absolute') break;
- }
- } while (element);
- return [valueL, valueT];
- },
-
- offsetParent: function(element) {
- if (element.offsetParent) return element.offsetParent;
- if (element == document.body) return element;
-
- while ((element = element.parentNode) && element != document.body)
- if (Element.getStyle(element, 'position') != 'static')
- return element;
-
- return document.body;
- },
-
- // caches x/y coordinate pair to use with overlap
- within: function(element, x, y) {
- if (this.includeScrollOffsets)
- return this.withinIncludingScrolloffsets(element, x, y);
- this.xcomp = x;
- this.ycomp = y;
- this.offset = this.cumulativeOffset(element);
-
- return (y >= this.offset[1] &&
- y < this.offset[1] + element.offsetHeight &&
- x >= this.offset[0] &&
- x < this.offset[0] + element.offsetWidth);
- },
-
- withinIncludingScrolloffsets: function(element, x, y) {
- var offsetcache = this.realOffset(element);
-
- this.xcomp = x + offsetcache[0] - this.deltaX;
- this.ycomp = y + offsetcache[1] - this.deltaY;
- this.offset = this.cumulativeOffset(element);
-
- return (this.ycomp >= this.offset[1] &&
- this.ycomp < this.offset[1] + element.offsetHeight &&
- this.xcomp >= this.offset[0] &&
- this.xcomp < this.offset[0] + element.offsetWidth);
- },
-
- // within must be called directly before
- overlap: function(mode, element) {
- if (!mode) return 0;
- if (mode == 'vertical')
- return ((this.offset[1] + element.offsetHeight) - this.ycomp) /
- element.offsetHeight;
- if (mode == 'horizontal')
- return ((this.offset[0] + element.offsetWidth) - this.xcomp) /
- element.offsetWidth;
- },
-
- clone: function(source, target) {
- source = $(source);
- target = $(target);
- target.style.position = 'absolute';
- var offsets = this.cumulativeOffset(source);
- target.style.top = offsets[1] + 'px';
- target.style.left = offsets[0] + 'px';
- target.style.width = source.offsetWidth + 'px';
- target.style.height = source.offsetHeight + 'px';
- },
-
- page: function(forElement) {
- var valueT = 0, valueL = 0;
-
- var element = forElement;
- do {
- valueT += element.offsetTop || 0;
- valueL += element.offsetLeft || 0;
-
- // Safari fix
- if (element.offsetParent==document.body)
- if (Element.getStyle(element,'position')=='absolute') break;
-
- } while (element = element.offsetParent);
-
- element = forElement;
- do {
- valueT -= element.scrollTop || 0;
- valueL -= element.scrollLeft || 0;
- } while (element = element.parentNode);
-
- return [valueL, valueT];
- },
-
- clone: function(source, target) {
- var options = Object.extend({
- setLeft: true,
- setTop: true,
- setWidth: true,
- setHeight: true,
- offsetTop: 0,
- offsetLeft: 0
- }, arguments[2] || {})
-
- // find page position of source
- source = $(source);
- var p = Position.page(source);
-
- // find coordinate system to use
- target = $(target);
- var delta = [0, 0];
- var parent = null;
- // delta [0,0] will do fine with position: fixed elements,
- // position:absolute needs offsetParent deltas
- if (Element.getStyle(target,'position') == 'absolute') {
- parent = Position.offsetParent(target);
- delta = Position.page(parent);
- }
-
- // correct by body offsets (fixes Safari)
- if (parent == document.body) {
- delta[0] -= document.body.offsetLeft;
- delta[1] -= document.body.offsetTop;
- }
-
- // set position
- if(options.setLeft) target.style.left = (p[0] - delta[0] + options.offsetLeft) + 'px';
- if(options.setTop) target.style.top = (p[1] - delta[1] + options.offsetTop) + 'px';
- if(options.setWidth) target.style.width = source.offsetWidth + 'px';
- if(options.setHeight) target.style.height = source.offsetHeight + 'px';
- },
-
- absolutize: function(element) {
- element = $(element);
- if (element.style.position == 'absolute') return;
- Position.prepare();
-
- var offsets = Position.positionedOffset(element);
- var top = offsets[1];
- var left = offsets[0];
- var width = element.clientWidth;
- var height = element.clientHeight;
-
- element._originalLeft = left - parseFloat(element.style.left || 0);
- element._originalTop = top - parseFloat(element.style.top || 0);
- element._originalWidth = element.style.width;
- element._originalHeight = element.style.height;
-
- element.style.position = 'absolute';
- element.style.top = top + 'px';;
- element.style.left = left + 'px';;
- element.style.width = width + 'px';;
- element.style.height = height + 'px';;
- },
-
- relativize: function(element) {
- element = $(element);
- if (element.style.position == 'relative') return;
- Position.prepare();
-
- element.style.position = 'relative';
- var top = parseFloat(element.style.top || 0) - (element._originalTop || 0);
- var left = parseFloat(element.style.left || 0) - (element._originalLeft || 0);
-
- element.style.top = top + 'px';
- element.style.left = left + 'px';
- element.style.height = element._originalHeight;
- element.style.width = element._originalWidth;
- }
-}
-
-// Safari returns margins on body which is incorrect if the child is absolutely
-// positioned. For performance reasons, redefine Position.cumulativeOffset for
-// KHTML/WebKit only.
-if (/Konqueror|Safari|KHTML/.test(navigator.userAgent)) {
- Position.cumulativeOffset = function(element) {
- var valueT = 0, valueL = 0;
- do {
- valueT += element.offsetTop || 0;
- valueL += element.offsetLeft || 0;
- if (element.offsetParent == document.body)
- if (Element.getStyle(element, 'position') == 'absolute') break;
-
- element = element.offsetParent;
- } while (element);
-
- return [valueL, valueT];
- }
-}
+++ /dev/null
-Rico.Color = Class.create();
-
-Rico.Color.prototype = {
-
- initialize: function(red, green, blue) {
- this.rgb = { r: red, g : green, b : blue };
- },
-
- setRed: function(r) {
- this.rgb.r = r;
- },
-
- setGreen: function(g) {
- this.rgb.g = g;
- },
-
- setBlue: function(b) {
- this.rgb.b = b;
- },
-
- setHue: function(h) {
-
- // get an HSB model, and set the new hue...
- var hsb = this.asHSB();
- hsb.h = h;
-
- // convert back to RGB...
- this.rgb = Rico.Color.HSBtoRGB(hsb.h, hsb.s, hsb.b);
- },
-
- setSaturation: function(s) {
- // get an HSB model, and set the new hue...
- var hsb = this.asHSB();
- hsb.s = s;
-
- // convert back to RGB and set values...
- this.rgb = Rico.Color.HSBtoRGB(hsb.h, hsb.s, hsb.b);
- },
-
- setBrightness: function(b) {
- // get an HSB model, and set the new hue...
- var hsb = this.asHSB();
- hsb.b = b;
-
- // convert back to RGB and set values...
- this.rgb = Rico.Color.HSBtoRGB( hsb.h, hsb.s, hsb.b );
- },
-
- darken: function(percent) {
- var hsb = this.asHSB();
- this.rgb = Rico.Color.HSBtoRGB(hsb.h, hsb.s, Math.max(hsb.b - percent,0));
- },
-
- brighten: function(percent) {
- var hsb = this.asHSB();
- this.rgb = Rico.Color.HSBtoRGB(hsb.h, hsb.s, Math.min(hsb.b + percent,1));
- },
-
- blend: function(other) {
- this.rgb.r = Math.floor((this.rgb.r + other.rgb.r)/2);
- this.rgb.g = Math.floor((this.rgb.g + other.rgb.g)/2);
- this.rgb.b = Math.floor((this.rgb.b + other.rgb.b)/2);
- },
-
- isBright: function() {
- var hsb = this.asHSB();
- return this.asHSB().b > 0.5;
- },
-
- isDark: function() {
- return ! this.isBright();
- },
-
- asRGB: function() {
- return "rgb(" + this.rgb.r + "," + this.rgb.g + "," + this.rgb.b + ")";
- },
-
- asHex: function() {
- return "#" + this.rgb.r.toColorPart() + this.rgb.g.toColorPart() + this.rgb.b.toColorPart();
- },
-
- asHSB: function() {
- return Rico.Color.RGBtoHSB(this.rgb.r, this.rgb.g, this.rgb.b);
- },
-
- toString: function() {
- return this.asHex();
- }
-
-};
-
-Rico.Color.createFromHex = function(hexCode) {
- if(hexCode.length==4) {
- var shortHexCode = hexCode;
- var hexCode = '#';
- for(var i=1;i<4;i++) hexCode += (shortHexCode.charAt(i) +
-shortHexCode.charAt(i));
- }
- if ( hexCode.indexOf('#') == 0 )
- hexCode = hexCode.substring(1);
- var red = hexCode.substring(0,2);
- var green = hexCode.substring(2,4);
- var blue = hexCode.substring(4,6);
- return new Rico.Color( parseInt(red,16), parseInt(green,16), parseInt(blue,16) );
-}
-
-/**
- * Factory method for creating a color from the background of
- * an HTML element.
- */
-Rico.Color.createColorFromBackground = function(elem) {
-
- var actualColor = RicoUtil.getElementsComputedStyle($(elem), "backgroundColor", "background-color");
-
- if ( actualColor == "transparent" && elem.parentNode )
- return Rico.Color.createColorFromBackground(elem.parentNode);
-
- if ( actualColor == null )
- return new Rico.Color(255,255,255);
-
- if ( actualColor.indexOf("rgb(") == 0 ) {
- var colors = actualColor.substring(4, actualColor.length - 1 );
- var colorArray = colors.split(",");
- return new Rico.Color( parseInt( colorArray[0] ),
- parseInt( colorArray[1] ),
- parseInt( colorArray[2] ) );
-
- }
- else if ( actualColor.indexOf("#") == 0 ) {
- return Rico.Color.createFromHex(actualColor);
- }
- else
- return new Rico.Color(255,255,255);
-}
-
-Rico.Color.HSBtoRGB = function(hue, saturation, brightness) {
-
- var red = 0;
- var green = 0;
- var blue = 0;
-
- if (saturation == 0) {
- red = parseInt(brightness * 255.0 + 0.5);
- green = red;
- blue = red;
- }
- else {
- var h = (hue - Math.floor(hue)) * 6.0;
- var f = h - Math.floor(h);
- var p = brightness * (1.0 - saturation);
- var q = brightness * (1.0 - saturation * f);
- var t = brightness * (1.0 - (saturation * (1.0 - f)));
-
- switch (parseInt(h)) {
- case 0:
- red = (brightness * 255.0 + 0.5);
- green = (t * 255.0 + 0.5);
- blue = (p * 255.0 + 0.5);
- break;
- case 1:
- red = (q * 255.0 + 0.5);
- green = (brightness * 255.0 + 0.5);
- blue = (p * 255.0 + 0.5);
- break;
- case 2:
- red = (p * 255.0 + 0.5);
- green = (brightness * 255.0 + 0.5);
- blue = (t * 255.0 + 0.5);
- break;
- case 3:
- red = (p * 255.0 + 0.5);
- green = (q * 255.0 + 0.5);
- blue = (brightness * 255.0 + 0.5);
- break;
- case 4:
- red = (t * 255.0 + 0.5);
- green = (p * 255.0 + 0.5);
- blue = (brightness * 255.0 + 0.5);
- break;
- case 5:
- red = (brightness * 255.0 + 0.5);
- green = (p * 255.0 + 0.5);
- blue = (q * 255.0 + 0.5);
- break;
- }
- }
-
- return { r : parseInt(red), g : parseInt(green) , b : parseInt(blue) };
-}
-
-Rico.Color.RGBtoHSB = function(r, g, b) {
-
- var hue;
- var saturation;
- var brightness;
-
- var cmax = (r > g) ? r : g;
- if (b > cmax)
- cmax = b;
-
- var cmin = (r < g) ? r : g;
- if (b < cmin)
- cmin = b;
-
- brightness = cmax / 255.0;
- if (cmax != 0)
- saturation = (cmax - cmin)/cmax;
- else
- saturation = 0;
-
- if (saturation == 0)
- hue = 0;
- else {
- var redc = (cmax - r)/(cmax - cmin);
- var greenc = (cmax - g)/(cmax - cmin);
- var bluec = (cmax - b)/(cmax - cmin);
-
- if (r == cmax)
- hue = bluec - greenc;
- else if (g == cmax)
- hue = 2.0 + redc - bluec;
- else
- hue = 4.0 + greenc - redc;
-
- hue = hue / 6.0;
- if (hue < 0)
- hue = hue + 1.0;
- }
-
- return { h : hue, s : saturation, b : brightness };
-}
-
+++ /dev/null
-/**
-*
-* Copyright 2005 Sabre Airline Solutions
-*
-* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
-* file except in compliance with the License. You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software distributed under the
-* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
-* either express or implied. See the License for the specific language governing permissions
-* and limitations under the License.
-**/
-
-
-var Rico = new Object();
-Rico.Corner = {
-
- round: function(e, options) {
- var e = $(e);
- this._setOptions(options);
-
- var color = this.options.color;
- if ( this.options.color == "fromElement" )
- color = this._background(e);
-
- var bgColor = this.options.bgColor;
- if ( this.options.bgColor == "fromParent" )
- bgColor = this._background(e.offsetParent);
-
- this._roundCornersImpl(e, color, bgColor);
- },
-
- /** This is a helper function to change the background
- * color of <div> that has had Rico rounded corners added.
- *
- * It seems we cannot just set the background color for the
- * outer <div> so each <span> element used to create the
- * corners must have its background color set individually.
- *
- * @param {DOM} theDiv - A child of the outer <div> that was
- * supplied to the `round` method.
- *
- * @param {str} newColor - The new background color to use.
- */
- changeColor: function(theDiv, newColor) {
-
- theDiv.style.backgroundColor = newColor;
-
- var spanElements = theDiv.parentNode.getElementsByTagName("span");
-
- for (var currIdx = 0; currIdx < spanElements.length; currIdx++) {
- spanElements[currIdx].style.backgroundColor = newColor;
- }
- },
-
-
- /** This is a helper function to change the background
- * opacity of <div> that has had Rico rounded corners added.
- *
- * See changeColor (above) for algorithm explanation
- *
- * @param {DOM} theDiv A child of the outer <div> that was
- * supplied to the `round` method.
- *
- * @param {int} newOpacity The new opacity to use (0-1).
- */
- changeOpacity: function(theDiv, newOpacity) {
-
- var mozillaOpacity = newOpacity;
- var ieOpacity = 'alpha(opacity=' + newOpacity * 100 + ')';
-
- theDiv.style.opacity = mozillaOpacity;
- theDiv.style.filter = ieOpacity;
-
- var spanElements = theDiv.parentNode.getElementsByTagName("span");
-
- for (var currIdx = 0; currIdx < spanElements.length; currIdx++) {
- spanElements[currIdx].style.opacity = mozillaOpacity;
- spanElements[currIdx].style.filter = ieOpacity;
- }
-
- },
-
- /** this function takes care of redoing the rico cornering
- *
- * you can't just call updateRicoCorners() again and pass it a
- * new options string. you have to first remove the divs that
- * rico puts on top and below the content div.
- *
- * @param {DOM} theDiv - A child of the outer <div> that was
- * supplied to the `round` method.
- *
- * @param {Array} options - list of options
- */
- reRound: function(theDiv, options) {
-
- var topRico = theDiv.parentNode.childNodes[0];
- //theDiv would be theDiv.parentNode.childNodes[1]
- var bottomRico = theDiv.parentNode.childNodes[2];
-
- theDiv.parentNode.removeChild(topRico);
- theDiv.parentNode.removeChild(bottomRico);
-
- this.round(theDiv.parentNode, options);
- },
-
- _roundCornersImpl: function(e, color, bgColor) {
- if(this.options.border)
- this._renderBorder(e,bgColor);
- if(this._isTopRounded())
- this._roundTopCorners(e,color,bgColor);
- if(this._isBottomRounded())
- this._roundBottomCorners(e,color,bgColor);
- },
-
- _renderBorder: function(el,bgColor) {
- var borderValue = "1px solid " + this._borderColor(bgColor);
- var borderL = "border-left: " + borderValue;
- var borderR = "border-right: " + borderValue;
- var style = "style='" + borderL + ";" + borderR + "'";
- el.innerHTML = "<div " + style + ">" + el.innerHTML + "</div>"
- },
-
- _roundTopCorners: function(el, color, bgColor) {
- var corner = this._createCorner(bgColor);
- for(var i=0 ; i < this.options.numSlices ; i++ )
- corner.appendChild(this._createCornerSlice(color,bgColor,i,"top"));
- el.style.paddingTop = 0;
- el.insertBefore(corner,el.firstChild);
- },
-
- _roundBottomCorners: function(el, color, bgColor) {
- var corner = this._createCorner(bgColor);
- for(var i=(this.options.numSlices-1) ; i >= 0 ; i-- )
- corner.appendChild(this._createCornerSlice(color,bgColor,i,"bottom"));
- el.style.paddingBottom = 0;
- el.appendChild(corner);
- },
-
- _createCorner: function(bgColor) {
- var corner = document.createElement("div");
- corner.style.backgroundColor = (this._isTransparent() ? "transparent" : bgColor);
- return corner;
- },
-
- _createCornerSlice: function(color,bgColor, n, position) {
- var slice = document.createElement("span");
-
- var inStyle = slice.style;
- inStyle.backgroundColor = color;
- inStyle.display = "block";
- inStyle.height = "1px";
- inStyle.overflow = "hidden";
- inStyle.fontSize = "1px";
-
- var borderColor = this._borderColor(color,bgColor);
- if ( this.options.border && n == 0 ) {
- inStyle.borderTopStyle = "solid";
- inStyle.borderTopWidth = "1px";
- inStyle.borderLeftWidth = "0px";
- inStyle.borderRightWidth = "0px";
- inStyle.borderBottomWidth = "0px";
- inStyle.height = "0px"; // assumes css compliant box model
- inStyle.borderColor = borderColor;
- }
- else if(borderColor) {
- inStyle.borderColor = borderColor;
- inStyle.borderStyle = "solid";
- inStyle.borderWidth = "0px 1px";
- }
-
- if ( !this.options.compact && (n == (this.options.numSlices-1)) )
- inStyle.height = "2px";
-
- this._setMargin(slice, n, position);
- this._setBorder(slice, n, position);
- return slice;
- },
-
- _setOptions: function(options) {
- this.options = {
- corners : "all",
- color : "fromElement",
- bgColor : "fromParent",
- blend : true,
- border : false,
- compact : false
- }
- Object.extend(this.options, options || {});
-
- this.options.numSlices = this.options.compact ? 2 : 4;
- if ( this._isTransparent() )
- this.options.blend = false;
- },
-
- _whichSideTop: function() {
- if ( this._hasString(this.options.corners, "all", "top") )
- return "";
-
- if ( this.options.corners.indexOf("tl") >= 0 && this.options.corners.indexOf("tr") >= 0 )
- return "";
-
- if (this.options.corners.indexOf("tl") >= 0)
- return "left";
- else if (this.options.corners.indexOf("tr") >= 0)
- return "right";
- return "";
- },
-
- _whichSideBottom: function() {
- if ( this._hasString(this.options.corners, "all", "bottom") )
- return "";
-
- if ( this.options.corners.indexOf("bl")>=0 && this.options.corners.indexOf("br")>=0 )
- return "";
-
- if(this.options.corners.indexOf("bl") >=0)
- return "left";
- else if(this.options.corners.indexOf("br")>=0)
- return "right";
- return "";
- },
-
- _borderColor : function(color,bgColor) {
- if ( color == "transparent" )
- return bgColor;
- else if ( this.options.border )
- return this.options.border;
- else if ( this.options.blend )
- return this._blend( bgColor, color );
- else
- return "";
- },
-
-
- _setMargin: function(el, n, corners) {
- var marginSize = this._marginSize(n);
- var whichSide = corners == "top" ? this._whichSideTop() : this._whichSideBottom();
-
- if ( whichSide == "left" ) {
- el.style.marginLeft = marginSize + "px"; el.style.marginRight = "0px";
- }
- else if ( whichSide == "right" ) {
- el.style.marginRight = marginSize + "px"; el.style.marginLeft = "0px";
- }
- else {
- el.style.marginLeft = marginSize + "px"; el.style.marginRight = marginSize + "px";
- }
- },
-
- _setBorder: function(el,n,corners) {
- var borderSize = this._borderSize(n);
- var whichSide = corners == "top" ? this._whichSideTop() : this._whichSideBottom();
- if ( whichSide == "left" ) {
- el.style.borderLeftWidth = borderSize + "px"; el.style.borderRightWidth = "0px";
- }
- else if ( whichSide == "right" ) {
- el.style.borderRightWidth = borderSize + "px"; el.style.borderLeftWidth = "0px";
- }
- else {
- el.style.borderLeftWidth = borderSize + "px"; el.style.borderRightWidth = borderSize + "px";
- }
- if (this.options.border != false)
- el.style.borderLeftWidth = borderSize + "px"; el.style.borderRightWidth = borderSize + "px";
- },
-
- _marginSize: function(n) {
- if ( this._isTransparent() )
- return 0;
-
- var marginSizes = [ 5, 3, 2, 1 ];
- var blendedMarginSizes = [ 3, 2, 1, 0 ];
- var compactMarginSizes = [ 2, 1 ];
- var smBlendedMarginSizes = [ 1, 0 ];
-
- if ( this.options.compact && this.options.blend )
- return smBlendedMarginSizes[n];
- else if ( this.options.compact )
- return compactMarginSizes[n];
- else if ( this.options.blend )
- return blendedMarginSizes[n];
- else
- return marginSizes[n];
- },
-
- _borderSize: function(n) {
- var transparentBorderSizes = [ 5, 3, 2, 1 ];
- var blendedBorderSizes = [ 2, 1, 1, 1 ];
- var compactBorderSizes = [ 1, 0 ];
- var actualBorderSizes = [ 0, 2, 0, 0 ];
-
- if ( this.options.compact && (this.options.blend || this._isTransparent()) )
- return 1;
- else if ( this.options.compact )
- return compactBorderSizes[n];
- else if ( this.options.blend )
- return blendedBorderSizes[n];
- else if ( this.options.border )
- return actualBorderSizes[n];
- else if ( this._isTransparent() )
- return transparentBorderSizes[n];
- return 0;
- },
-
- _hasString: function(str) { for(var i=1 ; i<arguments.length ; i++) if (str.indexOf(arguments[i]) >= 0) return true; return false; },
- _blend: function(c1, c2) { var cc1 = Rico.Color.createFromHex(c1); cc1.blend(Rico.Color.createFromHex(c2)); return cc1; },
- _background: function(el) { try { return Rico.Color.createColorFromBackground(el).asHex(); } catch(err) { return "#ffffff"; } },
- _isTransparent: function() { return this.options.color == "transparent"; },
- _isTopRounded: function() { return this._hasString(this.options.corners, "all", "top", "tl", "tr"); },
- _isBottomRounded: function() { return this._hasString(this.options.corners, "all", "bottom", "bl", "br"); },
- _hasSingleTextChild: function(el) { return el.childNodes.length == 1 && el.childNodes[0].nodeType == 3; }
-}
-<?xml version="1.0" encoding="UTF-8"?>\r
-<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/"\r
- xmlns:moz="http://www.mozilla.org/2006/browser/search/">\r
- <ShortName>OpenStreetMap</ShortName>\r
- <LongName>OpenStreetMap Search</LongName>\r
- <Description>Search for a place in OpenStreetMap, the Wiki World Map</Description>\r
- <InputEncoding>UTF-8</InputEncoding>\r
- <OutputEncoding>UTF-8</OutputEncoding>\r
- <Image width="16" height="16">data:image/png,%89PNG%0D%0A%1A%0A%00%00%00%0DIHDR%00%00%00%10%00%00%00%10%08%06%00%00%00%1F%F3%FFa%00%00%00%19tEXtSoftware%00www.inkscape.org%9B%EE%3C%1A%00%00%01'IDATx%9C%9D%93%B1q%C30%0CE%1F%5Dd%80l%90I%C4*%A7%22%95%CF%85J%97%AE%B2%82%3DC%CE%03%A0%B3%9B%B8f%95%A3%17H%93%05%5C%A7%C8%0A%3F%05E%8A%92l%E7.%D0%E9N%02%81%07%E0Cr%FCaf%A6%FC%BC%5E%AF%DD%F4%3C%3Bt%C5%87%99)%84P%0E%DA%B6%BD%0AI%00%A1%A8%A8%1E%263S%D7u%C9'F%FE%9B%80%0C%C9%C9%22%BD'%B0%0A%AC%86%2CJ%DB%0E%22%11%8F%2F%D4%B3%22%8D%F34%CE%13u%06R%0C%40%D7u%AA%01%C5r%40%0Dq%88%C6%F9i%E8%7C%8CX%5D%A9M%95%D6%A3%A2Ti%C3Xx%CA%9C%F5mf3h%11%B6%07%B8%0APh%97%DD%1E%9E%5E%08!%D0%B6m%F1%87%108%1E%8EY5%007%03%5Cv%7B%00%3E%BF%3E%F8~x%1E%CD%B89l%00%F0I%0FWw%00%20%DB%AEJr%B6%E5%FB%09%80%C6y%CE%7D%91%1AP%B6p%2B%D9%BB%06%18V%3A%B5E%9F%AC%5B%95%AFY%3F%EE%20%A2mW%AA%93%DFN%3F%A0%E1%9B%F0u%E5%BC%BC%89%88%BC.%1F%D5'%DF%FD%C1%EE%F8%FFg%BFp%96%DF%E2%DCw%25%2B%00%00%00%00IEND%AEB%60%82</Image>\r
- <Url type="text/html" method="post" template="http://www.openstreetmap.org/">\r
- <Param name="query" value="{searchTerms}"/>\r
- </Url>\r
- <Query role="example" searchTerms="Reigate" />\r
- <Developer>Jonathan Bennett</Developer>\r
- <AdultContent>false</AdultContent>\r
- <Attribution>Data &copy; OpenStreetMap contributors, Some Rights Reserved. CC by-sa 2.0. Geolocation provided by npemap.org.uk, geocoder.us, geocoder.ca and geonames.org.</Attribution>\r
-</OpenSearchDescription>\r
+<?xml version="1.0" encoding="UTF-8"?>
+<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/"
+ xmlns:moz="http://www.mozilla.org/2006/browser/search/">
+ <ShortName>OpenStreetMap</ShortName>
+ <LongName>OpenStreetMap Search</LongName>
+ <Description>Search for a place in OpenStreetMap, the Wiki World Map</Description>
+ <InputEncoding>UTF-8</InputEncoding>
+ <OutputEncoding>UTF-8</OutputEncoding>
+ <Image width="16" height="16">data:image/png,%89PNG%0D%0A%1A%0A%00%00%00%0DIHDR%00%00%00%10%00%00%00%10%08%06%00%00%00%1F%F3%FFa%00%00%00%19tEXtSoftware%00www.inkscape.org%9B%EE%3C%1A%00%00%01'IDATx%9C%9D%93%B1q%C30%0CE%1F%5Dd%80l%90I%C4*%A7%22%95%CF%85J%97%AE%B2%82%3DC%CE%03%A0%B3%9B%B8f%95%A3%17H%93%05%5C%A7%C8%0A%3F%05E%8A%92l%E7.%D0%E9N%02%81%07%E0Cr%FCaf%A6%FC%BC%5E%AF%DD%F4%3C%3Bt%C5%87%99)%84P%0E%DA%B6%BD%0AI%00%A1%A8%A8%1E%263S%D7u%C9'F%FE%9B%80%0C%C9%C9%22%BD'%B0%0A%AC%86%2CJ%DB%0E%22%11%8F%2F%D4%B3%22%8D%F34%CE%13u%06R%0C%40%D7u%AA%01%C5r%40%0Dq%88%C6%F9i%E8%7C%8CX%5D%A9M%95%D6%A3%A2Ti%C3Xx%CA%9C%F5mf3h%11%B6%07%B8%0APh%97%DD%1E%9E%5E%08!%D0%B6m%F1%87%108%1E%8EY5%007%03%5Cv%7B%00%3E%BF%3E%F8~x%1E%CD%B89l%00%F0I%0FWw%00%20%DB%AEJr%B6%E5%FB%09%80%C6y%CE%7D%91%1AP%B6p%2B%D9%BB%06%18V%3A%B5E%9F%AC%5B%95%AFY%3F%EE%20%A2mW%AA%93%DFN%3F%A0%E1%9B%F0u%E5%BC%BC%89%88%BC.%1F%D5'%DF%FD%C1%EE%F8%FFg%BFp%96%DF%E2%DCw%25%2B%00%00%00%00IEND%AEB%60%82</Image>
+ <Url type="text/html" method="post" template="http://www.openstreetmap.org/">
+ <Param name="query" value="{searchTerms}"/>
+ </Url>
+ <Query role="example" searchTerms="Reigate" />
+ <Developer>Jonathan Bennett</Developer>
+ <AdultContent>false</AdultContent>
+ <Attribution>Data &copy; OpenStreetMap contributors, Some Rights Reserved. CC by-sa 2.0. Geolocation provided by npemap.org.uk, geocoder.us, geocoder.ca and geonames.org.</Attribution>
+</OpenSearchDescription>
-= Composite Primary Keys for ActiveRecords\r
-\r
-== Summary\r
-\r
-ActiveRecords/Rails famously doesn't support composite primary keys. \r
-This RubyGem extends the activerecord gem to provide CPK support.\r
-\r
-== Installation\r
-\r
- gem install composite_primary_keys\r
- \r
-== Usage\r
- \r
- require 'composite_primary_keys'\r
- class ProductVariation\r
- set_primary_keys :product_id, :variation_seq\r
- end\r
- \r
- pv = ProductVariation.find(345, 12)\r
- \r
-It even supports composite foreign keys for associations.\r
-\r
-See http://compositekeys.rubyforge.org for more.\r
-\r
-== Running Tests\r
-\r
-See test/README.tests.txt\r
-\r
-== Url\r
-\r
-http://compositekeys.rubyforge.org\r
-\r
-== Questions, Discussion and Contributions\r
-\r
-http://groups.google.com/compositekeys\r
-\r
-== Author\r
-\r
-Written by Dr Nic Williams, drnicwilliams@gmail\r
-Contributions by many!\r
-\r
+= Composite Primary Keys for ActiveRecords
+
+== Summary
+
+ActiveRecords/Rails famously doesn't support composite primary keys.
+This RubyGem extends the activerecord gem to provide CPK support.
+
+== Installation
+
+ gem install composite_primary_keys
+
+== Usage
+
+ require 'composite_primary_keys'
+ class ProductVariation
+ set_primary_keys :product_id, :variation_seq
+ end
+
+ pv = ProductVariation.find(345, 12)
+
+It even supports composite foreign keys for associations.
+
+See http://compositekeys.rubyforge.org for more.
+
+== Running Tests
+
+See test/README.tests.txt
+
+== Url
+
+http://compositekeys.rubyforge.org
+
+== Questions, Discussion and Contributions
+
+http://groups.google.com/compositekeys
+
+== Author
+
+Written by Dr Nic Williams, drnicwilliams@gmail
+Contributions by many!
+
-require 'rubygems'\r
-require 'rake'\r
-require 'rake/clean'\r
-require 'rake/testtask'\r
-require 'rake/rdoctask'\r
-require 'rake/packagetask'\r
-require 'rake/gempackagetask'\r
-require 'rake/contrib/rubyforgepublisher'\r
-require 'fileutils'\r
-require 'hoe'\r
-include FileUtils\r
-require File.join(File.dirname(__FILE__), 'lib', 'composite_primary_keys', 'version')\r
-\r
-AUTHOR = "Dr Nic Williams"\r
-EMAIL = "drnicwilliams@gmail.com"\r
-DESCRIPTION = "Composite key support for ActiveRecords"\r
-GEM_NAME = "composite_primary_keys" # what ppl will type to install your gem\r
-if File.exists?("~/.rubyforge/user-config.yml")\r
- # TODO this should prob go in a local/ file\r
- config = YAML.load(File.read(File.expand_path("~/.rubyforge/user-config.yml")))\r
- RUBYFORGE_USERNAME = config["username"]\r
-end\r
-RUBYFORGE_PROJECT = "compositekeys"\r
-HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"\r
-\r
-REV = nil #File.read(".svn/entries")[/committed-rev="(\d+)"/, 1] rescue nil\r
-VERS = ENV['VERSION'] || (CompositePrimaryKeys::VERSION::STRING + (REV ? ".#{REV}" : ""))\r
-CLEAN.include ['**/.*.sw?', '*.gem', '.config','debug.log','*.db','logfile','log/**/*','**/.DS_Store', '.project']\r
-RDOC_OPTS = ['--quiet', '--title', "newgem documentation",\r
- "--opname", "index.html",\r
- "--line-numbers", \r
- "--main", "README",\r
- "--inline-source"]\r
-\r
-class Hoe\r
- def extra_deps \r
- @extra_deps.reject { |x| Array(x).first == 'hoe' } \r
- end \r
-end\r
-\r
-# Generate all the Rake tasks\r
-# Run 'rake -T' to see list of generated tasks (from gem root directory)\r
-hoe = Hoe.new(GEM_NAME, VERS) do |p|\r
- p.author = AUTHOR \r
- p.description = DESCRIPTION\r
- p.email = EMAIL\r
- p.summary = DESCRIPTION\r
- p.url = HOMEPATH\r
- p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT\r
- p.test_globs = ["test/**/test*.rb"]\r
- p.clean_globs |= CLEAN #An array of file patterns to delete on clean.\r
-\r
- # == Optional\r
- p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")\r
- p.extra_deps = [['activerecord', '>= 2.2.0']] #An array of rubygem dependencies.\r
- #p.spec_extras - A hash of extra values to set in the gemspec.\r
-end\r
-\r
-CHANGES = hoe.paragraphs_of('History.txt', 0..1).join("\n\n")\r
-PATH = RUBYFORGE_PROJECT\r
-hoe.remote_rdoc_dir = File.join(PATH.gsub(/^#{RUBYFORGE_PROJECT}\/?/,''), 'rdoc')\r
-\r
-PROJECT_ROOT = File.expand_path(".")\r
-\r
-require 'loader'\r
+require 'rubygems'
+require 'rake'
+require 'rake/clean'
+require 'rake/testtask'
+require 'rake/rdoctask'
+require 'rake/packagetask'
+require 'rake/gempackagetask'
+require 'rake/contrib/rubyforgepublisher'
+require 'fileutils'
+require 'hoe'
+include FileUtils
+require File.join(File.dirname(__FILE__), 'lib', 'composite_primary_keys', 'version')
+
+AUTHOR = "Dr Nic Williams"
+EMAIL = "drnicwilliams@gmail.com"
+DESCRIPTION = "Composite key support for ActiveRecords"
+GEM_NAME = "composite_primary_keys" # what ppl will type to install your gem
+if File.exists?("~/.rubyforge/user-config.yml")
+ # TODO this should prob go in a local/ file
+ config = YAML.load(File.read(File.expand_path("~/.rubyforge/user-config.yml")))
+ RUBYFORGE_USERNAME = config["username"]
+end
+RUBYFORGE_PROJECT = "compositekeys"
+HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
+
+REV = nil #File.read(".svn/entries")[/committed-rev="(\d+)"/, 1] rescue nil
+VERS = ENV['VERSION'] || (CompositePrimaryKeys::VERSION::STRING + (REV ? ".#{REV}" : ""))
+CLEAN.include ['**/.*.sw?', '*.gem', '.config','debug.log','*.db','logfile','log/**/*','**/.DS_Store', '.project']
+RDOC_OPTS = ['--quiet', '--title', "newgem documentation",
+ "--opname", "index.html",
+ "--line-numbers",
+ "--main", "README",
+ "--inline-source"]
+
+class Hoe
+ def extra_deps
+ @extra_deps.reject { |x| Array(x).first == 'hoe' }
+ end
+end
+
+# Generate all the Rake tasks
+# Run 'rake -T' to see list of generated tasks (from gem root directory)
+hoe = Hoe.new(GEM_NAME, VERS) do |p|
+ p.author = AUTHOR
+ p.description = DESCRIPTION
+ p.email = EMAIL
+ p.summary = DESCRIPTION
+ p.url = HOMEPATH
+ p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT
+ p.test_globs = ["test/**/test*.rb"]
+ p.clean_globs |= CLEAN #An array of file patterns to delete on clean.
+
+ # == Optional
+ p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
+ p.extra_deps = [['activerecord', '>= 2.2.0']] #An array of rubygem dependencies.
+ #p.spec_extras - A hash of extra values to set in the gemspec.
+end
+
+CHANGES = hoe.paragraphs_of('History.txt', 0..1).join("\n\n")
+PATH = RUBYFORGE_PROJECT
+hoe.remote_rdoc_dir = File.join(PATH.gsub(/^#{RUBYFORGE_PROJECT}\/?/,''), 'rdoc')
+
+PROJECT_ROOT = File.expand_path(".")
+
+require 'loader'
-require 'rbconfig'\r
-require 'find'\r
-require 'ftools'\r
-\r
-include Config\r
-\r
-# this was adapted from rdoc's install.rb by ways of Log4r\r
-\r
-$sitedir = CONFIG["sitelibdir"]\r
-unless $sitedir\r
- version = CONFIG["MAJOR"] + "." + CONFIG["MINOR"]\r
- $libdir = File.join(CONFIG["libdir"], "ruby", version)\r
- $sitedir = $:.find {|x| x =~ /site_ruby/ }\r
- if !$sitedir\r
- $sitedir = File.join($libdir, "site_ruby")\r
- elsif $sitedir !~ Regexp.quote(version)\r
- $sitedir = File.join($sitedir, version)\r
- end\r
-end\r
-\r
-# the acual gruntwork\r
-Dir.chdir("lib")\r
-\r
-Find.find("composite_primary_keys", "composite_primary_keys.rb") { |f|\r
- if f[-3..-1] == ".rb"\r
- File::install(f, File.join($sitedir, *f.split(/\//)), 0644, true)\r
- else\r
- File::makedirs(File.join($sitedir, *f.split(/\//)))\r
- end\r
-}\r
+require 'rbconfig'
+require 'find'
+require 'ftools'
+
+include Config
+
+# this was adapted from rdoc's install.rb by ways of Log4r
+
+$sitedir = CONFIG["sitelibdir"]
+unless $sitedir
+ version = CONFIG["MAJOR"] + "." + CONFIG["MINOR"]
+ $libdir = File.join(CONFIG["libdir"], "ruby", version)
+ $sitedir = $:.find {|x| x =~ /site_ruby/ }
+ if !$sitedir
+ $sitedir = File.join($libdir, "site_ruby")
+ elsif $sitedir !~ Regexp.quote(version)
+ $sitedir = File.join($sitedir, version)
+ end
+end
+
+# the acual gruntwork
+Dir.chdir("lib")
+
+Find.find("composite_primary_keys", "composite_primary_keys.rb") { |f|
+ if f[-3..-1] == ".rb"
+ File::install(f, File.join($sitedir, *f.split(/\//)), 0644, true)
+ else
+ File::makedirs(File.join($sitedir, *f.split(/\//)))
+ end
+}
-#--\r
-# Copyright (c) 2006 Nic Williams\r
-#\r
-# Permission is hereby granted, free of charge, to any person obtaining\r
-# a copy of this software and associated documentation files (the\r
-# "Software"), to deal in the Software without restriction, including\r
-# without limitation the rights to use, copy, modify, merge, publish,\r
-# distribute, sublicense, and/or sell copies of the Software, and to\r
-# permit persons to whom the Software is furnished to do so, subject to\r
-# the following conditions:\r
-#\r
-# The above copyright notice and this permission notice shall be\r
-# included in all copies or substantial portions of the Software.\r
-#\r
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
-# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
-# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
-# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\r
-# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\r
-# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\r
-# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
-#++\r
-\r
-$:.unshift(File.dirname(__FILE__)) unless\r
- $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))\r
-\r
-unless defined?(ActiveRecord)\r
- begin\r
- require 'active_record' \r
- rescue LoadError\r
- require 'rubygems'\r
- require_gem 'activerecord'\r
- end\r
-end\r
-\r
-require 'composite_primary_keys/fixtures'\r
-require 'composite_primary_keys/composite_arrays'\r
-require 'composite_primary_keys/associations'\r
-require 'composite_primary_keys/association_preload'\r
-require 'composite_primary_keys/reflection'\r
-require 'composite_primary_keys/base'\r
-require 'composite_primary_keys/calculations'\r
-require 'composite_primary_keys/migration'\r
-require 'composite_primary_keys/attribute_methods'\r
-\r
-ActiveRecord::Base.class_eval do\r
- include CompositePrimaryKeys::ActiveRecord::Base\r
-end\r
-\r
-Dir[File.dirname(__FILE__) + '/composite_primary_keys/connection_adapters/*.rb'].each do |adapter|\r
- begin\r
- require adapter.gsub('.rb','')\r
- rescue MissingSourceFile\r
- end\r
-end\r
+#--
+# Copyright (c) 2006 Nic Williams
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be
+# included in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#++
+
+$:.unshift(File.dirname(__FILE__)) unless
+ $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
+
+unless defined?(ActiveRecord)
+ begin
+ require 'active_record'
+ rescue LoadError
+ require 'rubygems'
+ require_gem 'activerecord'
+ end
+end
+
+require 'composite_primary_keys/fixtures'
+require 'composite_primary_keys/composite_arrays'
+require 'composite_primary_keys/associations'
+require 'composite_primary_keys/association_preload'
+require 'composite_primary_keys/reflection'
+require 'composite_primary_keys/base'
+require 'composite_primary_keys/calculations'
+require 'composite_primary_keys/migration'
+require 'composite_primary_keys/attribute_methods'
+
+ActiveRecord::Base.class_eval do
+ include CompositePrimaryKeys::ActiveRecord::Base
+end
+
+Dir[File.dirname(__FILE__) + '/composite_primary_keys/connection_adapters/*.rb'].each do |adapter|
+ begin
+ require adapter.gsub('.rb','')
+ rescue MissingSourceFile
+ end
+end
-module CompositePrimaryKeys\r
- module ActiveRecord #:nodoc:\r
- class CompositeKeyError < StandardError #:nodoc:\r
- end\r
-\r
- module Base #:nodoc:\r
-\r
- INVALID_FOR_COMPOSITE_KEYS = 'Not appropriate for composite primary keys'\r
- NOT_IMPLEMENTED_YET = 'Not implemented for composite primary keys yet'\r
-\r
- def self.append_features(base)\r
- super\r
- base.send(:include, InstanceMethods)\r
- base.extend(ClassMethods)\r
- end\r
-\r
- module ClassMethods\r
- def set_primary_keys(*keys)\r
- keys = keys.first if keys.first.is_a?(Array)\r
- keys = keys.map { |k| k.to_sym }\r
- cattr_accessor :primary_keys\r
- self.primary_keys = keys.to_composite_keys\r
-\r
- class_eval <<-EOV\r
- extend CompositeClassMethods\r
- include CompositeInstanceMethods\r
-\r
- include CompositePrimaryKeys::ActiveRecord::Associations\r
- include CompositePrimaryKeys::ActiveRecord::AssociationPreload\r
- include CompositePrimaryKeys::ActiveRecord::Calculations\r
- include CompositePrimaryKeys::ActiveRecord::AttributeMethods\r
- EOV\r
- end\r
-\r
- def composite?\r
- false\r
- end\r
- end\r
-\r
- module InstanceMethods\r
- def composite?; self.class.composite?; end\r
- end\r
-\r
- module CompositeInstanceMethods\r
-\r
- # A model instance's primary keys is always available as model.ids\r
- # whether you name it the default 'id' or set it to something else.\r
- def id\r
- attr_names = self.class.primary_keys\r
- CompositeIds.new(attr_names.map { |attr_name| read_attribute(attr_name) })\r
- end\r
- alias_method :ids, :id\r
-\r
- def to_param\r
- id.to_s\r
- end\r
-\r
- def id_before_type_cast #:nodoc:\r
- raise CompositeKeyError, CompositePrimaryKeys::ActiveRecord::Base::NOT_IMPLEMENTED_YET\r
- end\r
-\r
- def quoted_id #:nodoc:\r
- [self.class.primary_keys, ids].\r
- transpose.\r
- map {|attr_name,id| quote_value(id, column_for_attribute(attr_name))}.\r
- to_composite_ids\r
- end\r
-\r
- # Sets the primary ID.\r
- def id=(ids)\r
- ids = ids.split(ID_SEP) if ids.is_a?(String)\r
- ids.flatten!\r
- unless ids.is_a?(Array) and ids.length == self.class.primary_keys.length\r
- raise "#{self.class}.id= requires #{self.class.primary_keys.length} ids"\r
- end\r
- [primary_keys, ids].transpose.each {|key, an_id| write_attribute(key , an_id)}\r
- id\r
- end\r
-\r
- # Returns a clone of the record that hasn't been assigned an id yet and\r
- # is treated as a new record. Note that this is a "shallow" clone:\r
- # it copies the object's attributes only, not its associations.\r
- # The extent of a "deep" clone is application-specific and is therefore\r
- # left to the application to implement according to its need.\r
- def clone\r
- attrs = self.attributes_before_type_cast\r
- self.class.primary_keys.each {|key| attrs.delete(key.to_s)}\r
- self.class.new do |record|\r
- record.send :instance_variable_set, '@attributes', attrs\r
- end\r
- end\r
-\r
-\r
- private\r
- # The xx_without_callbacks methods are overwritten as that is the end of the alias chain\r
-\r
- # Creates a new record with values matching those of the instance attributes.\r
- def create_without_callbacks\r
- unless self.id\r
- raise CompositeKeyError, "Composite keys do not generated ids from sequences, you must provide id values"\r
- end\r
- attributes_minus_pks = attributes_with_quotes(false)\r
- quoted_pk_columns = self.class.primary_key.map { |col| connection.quote_column_name(col) }\r
- cols = quoted_column_names(attributes_minus_pks) << quoted_pk_columns\r
- vals = attributes_minus_pks.values << quoted_id\r
- connection.insert(\r
- "INSERT INTO #{self.class.quoted_table_name} " +\r
- "(#{cols.join(', ')}) " +\r
- "VALUES (#{vals.join(', ')})",\r
- "#{self.class.name} Create",\r
- self.class.primary_key,\r
- self.id\r
- )\r
- @new_record = false\r
- return true\r
- end\r
-\r
- # Updates the associated record with values matching those of the instance attributes.\r
- def update_without_callbacks\r
- where_clause_terms = [self.class.primary_key, quoted_id].transpose.map do |pair| \r
- "(#{connection.quote_column_name(pair[0])} = #{pair[1]})"\r
- end\r
- where_clause = where_clause_terms.join(" AND ")\r
- connection.update(\r
- "UPDATE #{self.class.quoted_table_name} " +\r
- "SET #{quoted_comma_pair_list(connection, attributes_with_quotes(false))} " +\r
- "WHERE #{where_clause}",\r
- "#{self.class.name} Update"\r
- )\r
- return true\r
- end\r
-\r
- # Deletes the record in the database and freezes this instance to reflect that no changes should\r
- # be made (since they can't be persisted).\r
- def destroy_without_callbacks\r
- where_clause_terms = [self.class.primary_key, quoted_id].transpose.map do |pair| \r
- "(#{connection.quote_column_name(pair[0])} = #{pair[1]})"\r
- end\r
- where_clause = where_clause_terms.join(" AND ")\r
- unless new_record?\r
- connection.delete(\r
- "DELETE FROM #{self.class.quoted_table_name} " +\r
- "WHERE #{where_clause}",\r
- "#{self.class.name} Destroy"\r
- )\r
- end\r
- freeze\r
- end\r
- end\r
-\r
- module CompositeClassMethods\r
- def primary_key; primary_keys; end\r
- def primary_key=(keys); primary_keys = keys; end\r
-\r
- def composite?\r
- true\r
- end\r
-\r
- #ids_to_s([[1,2],[7,3]]) -> "(1,2),(7,3)"\r
- #ids_to_s([[1,2],[7,3]], ',', ';') -> "1,2;7,3"\r
- def ids_to_s(many_ids, id_sep = CompositePrimaryKeys::ID_SEP, list_sep = ',', left_bracket = '(', right_bracket = ')')\r
- many_ids.map {|ids| "#{left_bracket}#{ids}#{right_bracket}"}.join(list_sep)\r
- end\r
- \r
- # Creates WHERE condition from list of composited ids\r
- # User.update_all({:role => 'admin'}, :conditions => composite_where_clause([[1, 2], [2, 2]])) #=> UPDATE admins SET admin.role='admin' WHERE (admin.type=1 AND admin.type2=2) OR (admin.type=2 AND admin.type2=2)\r
- # User.find(:all, :conditions => composite_where_clause([[1, 2], [2, 2]])) #=> SELECT * FROM admins WHERE (admin.type=1 AND admin.type2=2) OR (admin.type=2 AND admin.type2=2)\r
- def composite_where_clause(ids)\r
- if ids.is_a?(String)\r
- ids = [[ids]]\r
- elsif not ids.first.is_a?(Array) # if single comp key passed, turn into an array of 1\r
- ids = [ids.to_composite_ids]\r
- end\r
- \r
- ids.map do |id_set|\r
- [primary_keys, id_set].transpose.map do |key, id|\r
- "#{table_name}.#{key.to_s}=#{sanitize(id)}"\r
- end.join(" AND ")\r
- end.join(") OR (") \r
- end\r
-\r
- # Returns true if the given +ids+ represents the primary keys of a record in the database, false otherwise.\r
- # Example:\r
- # Person.exists?(5,7)\r
- def exists?(ids)\r
- if ids.is_a?(Array) && ids.first.is_a?(String)\r
- count(:conditions => ids) > 0\r
- else\r
- obj = find(ids) rescue false\r
- !obj.nil? and obj.is_a?(self) \r
- end\r
- end\r
-\r
- # Deletes the record with the given +ids+ without instantiating an object first, e.g. delete(1,2)\r
- # If an array of ids is provided (e.g. delete([1,2], [3,4]), all of them\r
- # are deleted.\r
- def delete(*ids)\r
- unless ids.is_a?(Array); raise "*ids must be an Array"; end\r
- ids = [ids.to_composite_ids] if not ids.first.is_a?(Array)\r
- where_clause = ids.map do |id_set|\r
- [primary_keys, id_set].transpose.map do |key, id|\r
- "#{quoted_table_name}.#{connection.quote_column_name(key.to_s)}=#{sanitize(id)}"\r
- end.join(" AND ")\r
- end.join(") OR (")\r
- delete_all([ "(#{where_clause})" ])\r
- end\r
-\r
- # Destroys the record with the given +ids+ by instantiating the object and calling #destroy (all the callbacks are the triggered).\r
- # If an array of ids is provided, all of them are destroyed.\r
- def destroy(*ids)\r
- unless ids.is_a?(Array); raise "*ids must be an Array"; end\r
- if ids.first.is_a?(Array)\r
- ids = ids.map{|compids| compids.to_composite_ids}\r
- else\r
- ids = ids.to_composite_ids\r
- end\r
- ids.first.is_a?(CompositeIds) ? ids.each { |id_set| find(id_set).destroy } : find(ids).destroy\r
- end\r
-\r
- # Returns an array of column objects for the table associated with this class.\r
- # Each column that matches to one of the primary keys has its\r
- # primary attribute set to true\r
- def columns\r
- unless @columns\r
- @columns = connection.columns(table_name, "#{name} Columns")\r
- @columns.each {|column| column.primary = primary_keys.include?(column.name.to_sym)}\r
- end\r
- @columns\r
- end\r
-\r
- ## DEACTIVATED METHODS ##\r
- public\r
- # Lazy-set the sequence name to the connection's default. This method\r
- # is only ever called once since set_sequence_name overrides it.\r
- def sequence_name #:nodoc:\r
- raise CompositeKeyError, CompositePrimaryKeys::ActiveRecord::Base::INVALID_FOR_COMPOSITE_KEYS\r
- end\r
-\r
- def reset_sequence_name #:nodoc:\r
- raise CompositeKeyError, CompositePrimaryKeys::ActiveRecord::Base::INVALID_FOR_COMPOSITE_KEYS\r
- end\r
-\r
- def set_primary_key(value = nil, &block)\r
- raise CompositeKeyError, CompositePrimaryKeys::ActiveRecord::Base::INVALID_FOR_COMPOSITE_KEYS\r
- end\r
-\r
- private\r
- def find_one(id, options)\r
- raise CompositeKeyError, CompositePrimaryKeys::ActiveRecord::Base::INVALID_FOR_COMPOSITE_KEYS\r
- end\r
-\r
- def find_some(ids, options)\r
- raise CompositeKeyError, CompositePrimaryKeys::ActiveRecord::Base::INVALID_FOR_COMPOSITE_KEYS\r
- end\r
-\r
- def find_from_ids(ids, options)\r
- ids = ids.first if ids.last == nil\r
- conditions = " AND (#{sanitize_sql(options[:conditions])})" if options[:conditions]\r
- # if ids is just a flat list, then its size must = primary_key.length (one id per primary key, in order)\r
- # if ids is list of lists, then each inner list must follow rule above\r
- if ids.first.is_a? String\r
- # find '2,1' -> ids = ['2,1']\r
- # find '2,1;7,3' -> ids = ['2,1;7,3']\r
- ids = ids.first.split(ID_SET_SEP).map {|id_set| id_set.split(ID_SEP).to_composite_ids}\r
- # find '2,1;7,3' -> ids = [['2','1'],['7','3']], inner [] are CompositeIds\r
- end\r
- ids = [ids.to_composite_ids] if not ids.first.kind_of?(Array)\r
- ids.each do |id_set|\r
- unless id_set.is_a?(Array)\r
- raise "Ids must be in an Array, instead received: #{id_set.inspect}"\r
- end\r
- unless id_set.length == primary_keys.length\r
- raise "#{id_set.inspect}: Incorrect number of primary keys for #{class_name}: #{primary_keys.inspect}"\r
- end\r
- end\r
-\r
- # Let keys = [:a, :b]\r
- # If ids = [[10, 50], [11, 51]], then :conditions => \r
- # "(#{quoted_table_name}.a, #{quoted_table_name}.b) IN ((10, 50), (11, 51))"\r
-\r
- conditions = ids.map do |id_set|\r
- [primary_keys, id_set].transpose.map do |key, id|\r
- col = columns_hash[key.to_s]\r
- val = quote_value(id, col)\r
- "#{quoted_table_name}.#{connection.quote_column_name(key.to_s)}=#{val}"\r
- end.join(" AND ")\r
- end.join(") OR (")\r
- \r
- options.update :conditions => "(#{conditions})"\r
-\r
- result = find_every(options)\r
-\r
- if result.size == ids.size\r
- ids.size == 1 ? result[0] : result\r
- else\r
- raise ::ActiveRecord::RecordNotFound, "Couldn't find all #{name.pluralize} with IDs (#{ids.inspect})#{conditions}"\r
- end\r
- end\r
- end\r
- end\r
- end\r
-end\r
-\r
-\r
-module ActiveRecord\r
- ID_SEP = ','\r
- ID_SET_SEP = ';'\r
-\r
- class Base\r
- # Allows +attr_name+ to be the list of primary_keys, and returns the id\r
- # of the object\r
- # e.g. @object[@object.class.primary_key] => [1,1]\r
- def [](attr_name)\r
- if attr_name.is_a?(String) and attr_name != attr_name.split(ID_SEP).first\r
- attr_name = attr_name.split(ID_SEP)\r
- end\r
- attr_name.is_a?(Array) ?\r
- attr_name.map {|name| read_attribute(name)} :\r
- read_attribute(attr_name)\r
- end\r
-\r
- # Updates the attribute identified by <tt>attr_name</tt> with the specified +value+.\r
- # (Alias for the protected write_attribute method).\r
- def []=(attr_name, value)\r
- if attr_name.is_a?(String) and attr_name != attr_name.split(ID_SEP).first\r
- attr_name = attr_name.split(ID_SEP)\r
- end\r
-\r
- if attr_name.is_a? Array\r
- value = value.split(ID_SEP) if value.is_a? String\r
- unless value.length == attr_name.length\r
- raise "Number of attr_names and values do not match"\r
- end\r
- #breakpoint\r
- [attr_name, value].transpose.map {|name,val| write_attribute(name.to_s, val)}\r
- else\r
- write_attribute(attr_name, value)\r
- end\r
- end\r
- end\r
-end\r
+module CompositePrimaryKeys
+ module ActiveRecord #:nodoc:
+ class CompositeKeyError < StandardError #:nodoc:
+ end
+
+ module Base #:nodoc:
+
+ INVALID_FOR_COMPOSITE_KEYS = 'Not appropriate for composite primary keys'
+ NOT_IMPLEMENTED_YET = 'Not implemented for composite primary keys yet'
+
+ def self.append_features(base)
+ super
+ base.send(:include, InstanceMethods)
+ base.extend(ClassMethods)
+ end
+
+ module ClassMethods
+ def set_primary_keys(*keys)
+ keys = keys.first if keys.first.is_a?(Array)
+ keys = keys.map { |k| k.to_sym }
+ cattr_accessor :primary_keys
+ self.primary_keys = keys.to_composite_keys
+
+ class_eval <<-EOV
+ extend CompositeClassMethods
+ include CompositeInstanceMethods
+
+ include CompositePrimaryKeys::ActiveRecord::Associations
+ include CompositePrimaryKeys::ActiveRecord::AssociationPreload
+ include CompositePrimaryKeys::ActiveRecord::Calculations
+ include CompositePrimaryKeys::ActiveRecord::AttributeMethods
+ EOV
+ end
+
+ def composite?
+ false
+ end
+ end
+
+ module InstanceMethods
+ def composite?; self.class.composite?; end
+ end
+
+ module CompositeInstanceMethods
+
+ # A model instance's primary keys is always available as model.ids
+ # whether you name it the default 'id' or set it to something else.
+ def id
+ attr_names = self.class.primary_keys
+ CompositeIds.new(attr_names.map { |attr_name| read_attribute(attr_name) })
+ end
+ alias_method :ids, :id
+
+ def to_param
+ id.to_s
+ end
+
+ def id_before_type_cast #:nodoc:
+ raise CompositeKeyError, CompositePrimaryKeys::ActiveRecord::Base::NOT_IMPLEMENTED_YET
+ end
+
+ def quoted_id #:nodoc:
+ [self.class.primary_keys, ids].
+ transpose.
+ map {|attr_name,id| quote_value(id, column_for_attribute(attr_name))}.
+ to_composite_ids
+ end
+
+ # Sets the primary ID.
+ def id=(ids)
+ ids = ids.split(ID_SEP) if ids.is_a?(String)
+ ids.flatten!
+ unless ids.is_a?(Array) and ids.length == self.class.primary_keys.length
+ raise "#{self.class}.id= requires #{self.class.primary_keys.length} ids"
+ end
+ [primary_keys, ids].transpose.each {|key, an_id| write_attribute(key , an_id)}
+ id
+ end
+
+ # Returns a clone of the record that hasn't been assigned an id yet and
+ # is treated as a new record. Note that this is a "shallow" clone:
+ # it copies the object's attributes only, not its associations.
+ # The extent of a "deep" clone is application-specific and is therefore
+ # left to the application to implement according to its need.
+ def clone
+ attrs = self.attributes_before_type_cast
+ self.class.primary_keys.each {|key| attrs.delete(key.to_s)}
+ self.class.new do |record|
+ record.send :instance_variable_set, '@attributes', attrs
+ end
+ end
+
+
+ private
+ # The xx_without_callbacks methods are overwritten as that is the end of the alias chain
+
+ # Creates a new record with values matching those of the instance attributes.
+ def create_without_callbacks
+ unless self.id
+ raise CompositeKeyError, "Composite keys do not generated ids from sequences, you must provide id values"
+ end
+ attributes_minus_pks = attributes_with_quotes(false)
+ quoted_pk_columns = self.class.primary_key.map { |col| connection.quote_column_name(col) }
+ cols = quoted_column_names(attributes_minus_pks) << quoted_pk_columns
+ vals = attributes_minus_pks.values << quoted_id
+ connection.insert(
+ "INSERT INTO #{self.class.quoted_table_name} " +
+ "(#{cols.join(', ')}) " +
+ "VALUES (#{vals.join(', ')})",
+ "#{self.class.name} Create",
+ self.class.primary_key,
+ self.id
+ )
+ @new_record = false
+ return true
+ end
+
+ # Updates the associated record with values matching those of the instance attributes.
+ def update_without_callbacks
+ where_clause_terms = [self.class.primary_key, quoted_id].transpose.map do |pair|
+ "(#{connection.quote_column_name(pair[0])} = #{pair[1]})"
+ end
+ where_clause = where_clause_terms.join(" AND ")
+ connection.update(
+ "UPDATE #{self.class.quoted_table_name} " +
+ "SET #{quoted_comma_pair_list(connection, attributes_with_quotes(false))} " +
+ "WHERE #{where_clause}",
+ "#{self.class.name} Update"
+ )
+ return true
+ end
+
+ # Deletes the record in the database and freezes this instance to reflect that no changes should
+ # be made (since they can't be persisted).
+ def destroy_without_callbacks
+ where_clause_terms = [self.class.primary_key, quoted_id].transpose.map do |pair|
+ "(#{connection.quote_column_name(pair[0])} = #{pair[1]})"
+ end
+ where_clause = where_clause_terms.join(" AND ")
+ unless new_record?
+ connection.delete(
+ "DELETE FROM #{self.class.quoted_table_name} " +
+ "WHERE #{where_clause}",
+ "#{self.class.name} Destroy"
+ )
+ end
+ freeze
+ end
+ end
+
+ module CompositeClassMethods
+ def primary_key; primary_keys; end
+ def primary_key=(keys); primary_keys = keys; end
+
+ def composite?
+ true
+ end
+
+ #ids_to_s([[1,2],[7,3]]) -> "(1,2),(7,3)"
+ #ids_to_s([[1,2],[7,3]], ',', ';') -> "1,2;7,3"
+ def ids_to_s(many_ids, id_sep = CompositePrimaryKeys::ID_SEP, list_sep = ',', left_bracket = '(', right_bracket = ')')
+ many_ids.map {|ids| "#{left_bracket}#{ids}#{right_bracket}"}.join(list_sep)
+ end
+
+ # Creates WHERE condition from list of composited ids
+ # User.update_all({:role => 'admin'}, :conditions => composite_where_clause([[1, 2], [2, 2]])) #=> UPDATE admins SET admin.role='admin' WHERE (admin.type=1 AND admin.type2=2) OR (admin.type=2 AND admin.type2=2)
+ # User.find(:all, :conditions => composite_where_clause([[1, 2], [2, 2]])) #=> SELECT * FROM admins WHERE (admin.type=1 AND admin.type2=2) OR (admin.type=2 AND admin.type2=2)
+ def composite_where_clause(ids)
+ if ids.is_a?(String)
+ ids = [[ids]]
+ elsif not ids.first.is_a?(Array) # if single comp key passed, turn into an array of 1
+ ids = [ids.to_composite_ids]
+ end
+
+ ids.map do |id_set|
+ [primary_keys, id_set].transpose.map do |key, id|
+ "#{table_name}.#{key.to_s}=#{sanitize(id)}"
+ end.join(" AND ")
+ end.join(") OR (")
+ end
+
+ # Returns true if the given +ids+ represents the primary keys of a record in the database, false otherwise.
+ # Example:
+ # Person.exists?(5,7)
+ def exists?(ids)
+ if ids.is_a?(Array) && ids.first.is_a?(String)
+ count(:conditions => ids) > 0
+ else
+ obj = find(ids) rescue false
+ !obj.nil? and obj.is_a?(self)
+ end
+ end
+
+ # Deletes the record with the given +ids+ without instantiating an object first, e.g. delete(1,2)
+ # If an array of ids is provided (e.g. delete([1,2], [3,4]), all of them
+ # are deleted.
+ def delete(*ids)
+ unless ids.is_a?(Array); raise "*ids must be an Array"; end
+ ids = [ids.to_composite_ids] if not ids.first.is_a?(Array)
+ where_clause = ids.map do |id_set|
+ [primary_keys, id_set].transpose.map do |key, id|
+ "#{quoted_table_name}.#{connection.quote_column_name(key.to_s)}=#{sanitize(id)}"
+ end.join(" AND ")
+ end.join(") OR (")
+ delete_all([ "(#{where_clause})" ])
+ end
+
+ # Destroys the record with the given +ids+ by instantiating the object and calling #destroy (all the callbacks are the triggered).
+ # If an array of ids is provided, all of them are destroyed.
+ def destroy(*ids)
+ unless ids.is_a?(Array); raise "*ids must be an Array"; end
+ if ids.first.is_a?(Array)
+ ids = ids.map{|compids| compids.to_composite_ids}
+ else
+ ids = ids.to_composite_ids
+ end
+ ids.first.is_a?(CompositeIds) ? ids.each { |id_set| find(id_set).destroy } : find(ids).destroy
+ end
+
+ # Returns an array of column objects for the table associated with this class.
+ # Each column that matches to one of the primary keys has its
+ # primary attribute set to true
+ def columns
+ unless @columns
+ @columns = connection.columns(table_name, "#{name} Columns")
+ @columns.each {|column| column.primary = primary_keys.include?(column.name.to_sym)}
+ end
+ @columns
+ end
+
+ ## DEACTIVATED METHODS ##
+ public
+ # Lazy-set the sequence name to the connection's default. This method
+ # is only ever called once since set_sequence_name overrides it.
+ def sequence_name #:nodoc:
+ raise CompositeKeyError, CompositePrimaryKeys::ActiveRecord::Base::INVALID_FOR_COMPOSITE_KEYS
+ end
+
+ def reset_sequence_name #:nodoc:
+ raise CompositeKeyError, CompositePrimaryKeys::ActiveRecord::Base::INVALID_FOR_COMPOSITE_KEYS
+ end
+
+ def set_primary_key(value = nil, &block)
+ raise CompositeKeyError, CompositePrimaryKeys::ActiveRecord::Base::INVALID_FOR_COMPOSITE_KEYS
+ end
+
+ private
+ def find_one(id, options)
+ raise CompositeKeyError, CompositePrimaryKeys::ActiveRecord::Base::INVALID_FOR_COMPOSITE_KEYS
+ end
+
+ def find_some(ids, options)
+ raise CompositeKeyError, CompositePrimaryKeys::ActiveRecord::Base::INVALID_FOR_COMPOSITE_KEYS
+ end
+
+ def find_from_ids(ids, options)
+ ids = ids.first if ids.last == nil
+ conditions = " AND (#{sanitize_sql(options[:conditions])})" if options[:conditions]
+ # if ids is just a flat list, then its size must = primary_key.length (one id per primary key, in order)
+ # if ids is list of lists, then each inner list must follow rule above
+ if ids.first.is_a? String
+ # find '2,1' -> ids = ['2,1']
+ # find '2,1;7,3' -> ids = ['2,1;7,3']
+ ids = ids.first.split(ID_SET_SEP).map {|id_set| id_set.split(ID_SEP).to_composite_ids}
+ # find '2,1;7,3' -> ids = [['2','1'],['7','3']], inner [] are CompositeIds
+ end
+ ids = [ids.to_composite_ids] if not ids.first.kind_of?(Array)
+ ids.each do |id_set|
+ unless id_set.is_a?(Array)
+ raise "Ids must be in an Array, instead received: #{id_set.inspect}"
+ end
+ unless id_set.length == primary_keys.length
+ raise "#{id_set.inspect}: Incorrect number of primary keys for #{class_name}: #{primary_keys.inspect}"
+ end
+ end
+
+ # Let keys = [:a, :b]
+ # If ids = [[10, 50], [11, 51]], then :conditions =>
+ # "(#{quoted_table_name}.a, #{quoted_table_name}.b) IN ((10, 50), (11, 51))"
+
+ conditions = ids.map do |id_set|
+ [primary_keys, id_set].transpose.map do |key, id|
+ col = columns_hash[key.to_s]
+ val = quote_value(id, col)
+ "#{quoted_table_name}.#{connection.quote_column_name(key.to_s)}=#{val}"
+ end.join(" AND ")
+ end.join(") OR (")
+
+ options.update :conditions => "(#{conditions})"
+
+ result = find_every(options)
+
+ if result.size == ids.size
+ ids.size == 1 ? result[0] : result
+ else
+ raise ::ActiveRecord::RecordNotFound, "Couldn't find all #{name.pluralize} with IDs (#{ids.inspect})#{conditions}"
+ end
+ end
+ end
+ end
+ end
+end
+
+
+module ActiveRecord
+ ID_SEP = ','
+ ID_SET_SEP = ';'
+
+ class Base
+ # Allows +attr_name+ to be the list of primary_keys, and returns the id
+ # of the object
+ # e.g. @object[@object.class.primary_key] => [1,1]
+ def [](attr_name)
+ if attr_name.is_a?(String) and attr_name != attr_name.split(ID_SEP).first
+ attr_name = attr_name.split(ID_SEP)
+ end
+ attr_name.is_a?(Array) ?
+ attr_name.map {|name| read_attribute(name)} :
+ read_attribute(attr_name)
+ end
+
+ # Updates the attribute identified by <tt>attr_name</tt> with the specified +value+.
+ # (Alias for the protected write_attribute method).
+ def []=(attr_name, value)
+ if attr_name.is_a?(String) and attr_name != attr_name.split(ID_SEP).first
+ attr_name = attr_name.split(ID_SEP)
+ end
+
+ if attr_name.is_a? Array
+ value = value.split(ID_SEP) if value.is_a? String
+ unless value.length == attr_name.length
+ raise "Number of attr_names and values do not match"
+ end
+ #breakpoint
+ [attr_name, value].transpose.map {|name,val| write_attribute(name.to_s, val)}
+ else
+ write_attribute(attr_name, value)
+ end
+ end
+ end
+end
-module CompositePrimaryKeys\r
- ID_SEP = ','\r
- ID_SET_SEP = ';'\r
-\r
- module ArrayExtension\r
- def to_composite_keys\r
- CompositeKeys.new(self)\r
- end\r
-\r
- def to_composite_ids\r
- CompositeIds.new(self)\r
- end\r
- end\r
-\r
- class CompositeArray < Array\r
- def to_s\r
- join(ID_SEP)\r
- end\r
- end\r
-\r
- class CompositeKeys < CompositeArray\r
-\r
- end\r
-\r
- class CompositeIds < CompositeArray\r
-\r
- end\r
-end\r
-\r
-Array.send(:include, CompositePrimaryKeys::ArrayExtension)\r
+module CompositePrimaryKeys
+ ID_SEP = ','
+ ID_SET_SEP = ';'
+
+ module ArrayExtension
+ def to_composite_keys
+ CompositeKeys.new(self)
+ end
+
+ def to_composite_ids
+ CompositeIds.new(self)
+ end
+ end
+
+ class CompositeArray < Array
+ def to_s
+ join(ID_SEP)
+ end
+ end
+
+ class CompositeKeys < CompositeArray
+
+ end
+
+ class CompositeIds < CompositeArray
+
+ end
+end
+
+Array.send(:include, CompositePrimaryKeys::ArrayExtension)
-module ActiveRecord\r
- module Reflection\r
- class AssociationReflection\r
- def primary_key_name\r
- return @primary_key_name if @primary_key_name\r
- case\r
- when macro == :belongs_to\r
- @primary_key_name = options[:foreign_key] || class_name.foreign_key\r
- when options[:as]\r
- @primary_key_name = options[:foreign_key] || "#{options[:as]}_id"\r
- else\r
- @primary_key_name = options[:foreign_key] || active_record.name.foreign_key\r
- end\r
- @primary_key_name = @primary_key_name.to_composite_keys.to_s if @primary_key_name.is_a? Array\r
- @primary_key_name\r
- end\r
- end\r
- end\r
+module ActiveRecord
+ module Reflection
+ class AssociationReflection
+ def primary_key_name
+ return @primary_key_name if @primary_key_name
+ case
+ when macro == :belongs_to
+ @primary_key_name = options[:foreign_key] || class_name.foreign_key
+ when options[:as]
+ @primary_key_name = options[:foreign_key] || "#{options[:as]}_id"
+ else
+ @primary_key_name = options[:foreign_key] || active_record.name.foreign_key
+ end
+ @primary_key_name = @primary_key_name.to_composite_keys.to_s if @primary_key_name.is_a? Array
+ @primary_key_name
+ end
+ end
+ end
end
\ No newline at end of file
-module CompositePrimaryKeys\r
- module VERSION #:nodoc:\r
- MAJOR = 2\r
- MINOR = 2\r
- TINY = 2\r
- STRING = [MAJOR, MINOR, TINY].join('.')\r
- end\r
-end\r
+module CompositePrimaryKeys
+ module VERSION #:nodoc:
+ MAJOR = 2
+ MINOR = 2
+ TINY = 2
+ STRING = [MAJOR, MINOR, TINY].join('.')
+ end
+end
-class Article < ActiveRecord::Base\r
- has_many :readings\r
- has_many :users, :through => :readings\r
-end\r
-\r
+class Article < ActiveRecord::Base
+ has_many :readings
+ has_many :users, :through => :readings
+end
+
-first:\r
- id: 1\r
- name: Article One\r
-second:\r
- id: 2\r
+first:
+ id: 1
+ name: Article One
+second:
+ id: 2
name: Article Two
\ No newline at end of file
-class Product < ActiveRecord::Base\r
- set_primary_keys :id # redundant\r
- has_many :product_tariffs, :foreign_key => :product_id\r
- has_one :product_tariff, :foreign_key => :product_id\r
-\r
- has_many :tariffs, :through => :product_tariffs, :foreign_key => [:tariff_id, :tariff_start_date]\r
-end\r
+class Product < ActiveRecord::Base
+ set_primary_keys :id # redundant
+ has_many :product_tariffs, :foreign_key => :product_id
+ has_one :product_tariff, :foreign_key => :product_id
+
+ has_many :tariffs, :through => :product_tariffs, :foreign_key => [:tariff_id, :tariff_start_date]
+end
-class ProductTariff < ActiveRecord::Base\r
- set_primary_keys :product_id, :tariff_id, :tariff_start_date\r
- belongs_to :product, :foreign_key => :product_id\r
- belongs_to :tariff, :foreign_key => [:tariff_id, :tariff_start_date]\r
-end\r
+class ProductTariff < ActiveRecord::Base
+ set_primary_keys :product_id, :tariff_id, :tariff_start_date
+ belongs_to :product, :foreign_key => :product_id
+ belongs_to :tariff, :foreign_key => [:tariff_id, :tariff_start_date]
+end
-first_flat:\r
- product_id: 1\r
- tariff_id: 1\r
- tariff_start_date: <%= Date.today.to_s(:db) %>\r
-first_free: \r
- product_id: 1\r
- tariff_id: 2\r
- tariff_start_date: <%= Date.today.to_s(:db) %>\r
-second_free:\r
- product_id: 2\r
- tariff_id: 2\r
- tariff_start_date: <%= Date.today.to_s(:db) %>\r
+first_flat:
+ product_id: 1
+ tariff_id: 1
+ tariff_start_date: <%= Date.today.to_s(:db) %>
+first_free:
+ product_id: 1
+ tariff_id: 2
+ tariff_start_date: <%= Date.today.to_s(:db) %>
+second_free:
+ product_id: 2
+ tariff_id: 2
+ tariff_start_date: <%= Date.today.to_s(:db) %>
-first_product:\r
- id: 1\r
- name: Product One\r
-second_product:\r
- id: 2\r
+first_product:
+ id: 1
+ name: Product One
+second_product:
+ id: 2
name: Product Two
\ No newline at end of file
-class Reading < ActiveRecord::Base\r
- belongs_to :article\r
- belongs_to :user\r
-end \r
+class Reading < ActiveRecord::Base
+ belongs_to :article
+ belongs_to :user
+end
-santiago_first:\r
- id: 1\r
- user_id: 1\r
- article_id: 1\r
- rating: 4\r
-santiago_second:\r
- id: 2\r
- user_id: 1\r
- article_id: 2\r
+santiago_first:
+ id: 1
+ user_id: 1
+ article_id: 1
+ rating: 4
+santiago_second:
+ id: 2
+ user_id: 1
+ article_id: 2
rating: 5
\ No newline at end of file
-class ReferenceCode < ActiveRecord::Base\r
- set_primary_keys :reference_type_id, :reference_code\r
- \r
- belongs_to :reference_type, :foreign_key => "reference_type_id"\r
- \r
- validates_presence_of :reference_code, :code_label, :abbreviation\r
-end\r
+class ReferenceCode < ActiveRecord::Base
+ set_primary_keys :reference_type_id, :reference_code
+
+ belongs_to :reference_type, :foreign_key => "reference_type_id"
+
+ validates_presence_of :reference_code, :code_label, :abbreviation
+end
-name_prefix_mr:\r
- reference_type_id: 1\r
- reference_code: 1\r
- code_label: MR\r
- abbreviation: Mr\r
-name_prefix_mrs:\r
- reference_type_id: 1\r
- reference_code: 2\r
- code_label: MRS\r
- abbreviation: Mrs\r
-name_prefix_ms:\r
- reference_type_id: 1\r
- reference_code: 3\r
- code_label: MS\r
- abbreviation: Ms\r
- \r
-gender_male:\r
- reference_type_id: 2\r
- reference_code: 1\r
- code_label: MALE\r
- abbreviation: Male\r
-gender_female:\r
- reference_type_id: 2\r
- reference_code: 2\r
- code_label: FEMALE\r
- abbreviation: Female\r
-\r
+name_prefix_mr:
+ reference_type_id: 1
+ reference_code: 1
+ code_label: MR
+ abbreviation: Mr
+name_prefix_mrs:
+ reference_type_id: 1
+ reference_code: 2
+ code_label: MRS
+ abbreviation: Mrs
+name_prefix_ms:
+ reference_type_id: 1
+ reference_code: 3
+ code_label: MS
+ abbreviation: Ms
+
+gender_male:
+ reference_type_id: 2
+ reference_code: 1
+ code_label: MALE
+ abbreviation: Male
+gender_female:
+ reference_type_id: 2
+ reference_code: 2
+ code_label: FEMALE
+ abbreviation: Female
+
\ No newline at end of file
-class ReferenceType < ActiveRecord::Base\r
- set_primary_key :reference_type_id\r
- has_many :reference_codes, :foreign_key => "reference_type_id"\r
- \r
- validates_presence_of :type_label, :abbreviation\r
- validates_uniqueness_of :type_label\r
-end\r
+class ReferenceType < ActiveRecord::Base
+ set_primary_key :reference_type_id
+ has_many :reference_codes, :foreign_key => "reference_type_id"
+
+ validates_presence_of :type_label, :abbreviation
+ validates_uniqueness_of :type_label
+end
-name_prefix:\r
- reference_type_id: 1\r
- type_label: NAME_PREFIX\r
- abbreviation: Name Prefix\r
-\r
-gender:\r
- reference_type_id: 2\r
- type_label: GENDER\r
- abbreviation: Gender\r
+name_prefix:
+ reference_type_id: 1
+ type_label: NAME_PREFIX
+ abbreviation: Name Prefix
+
+gender:
+ reference_type_id: 2
+ type_label: GENDER
+ abbreviation: Gender
-class Suburb < ActiveRecord::Base\r
- set_primary_keys :city_id, :suburb_id\r
- has_many :streets, :foreign_key => [:city_id, :suburb_id]\r
- has_many :first_streets, :foreign_key => [:city_id, :suburb_id], \r
- :class_name => 'Street', :conditions => "streets.name = 'First Street'"\r
+class Suburb < ActiveRecord::Base
+ set_primary_keys :city_id, :suburb_id
+ has_many :streets, :foreign_key => [:city_id, :suburb_id]
+ has_many :first_streets, :foreign_key => [:city_id, :suburb_id],
+ :class_name => 'Street', :conditions => "streets.name = 'First Street'"
end
\ No newline at end of file
-first:\r
- city_id: 1\r
- suburb_id: 1\r
- name: First Suburb\r
-second:\r
- city_id: 2\r
- suburb_id: 1\r
- name: Second Suburb\r
+first:
+ city_id: 1
+ suburb_id: 1
+ name: First Suburb
+second:
+ city_id: 2
+ suburb_id: 1
+ name: Second Suburb
\ No newline at end of file
-class Tariff < ActiveRecord::Base\r
- set_primary_keys [:tariff_id, :start_date]\r
- has_many :product_tariffs, :foreign_key => [:tariff_id, :tariff_start_date]\r
- has_one :product_tariff, :foreign_key => [:tariff_id, :tariff_start_date]\r
- has_many :products, :through => :product_tariffs, :foreign_key => [:tariff_id, :tariff_start_date]\r
-end\r
+class Tariff < ActiveRecord::Base
+ set_primary_keys [:tariff_id, :start_date]
+ has_many :product_tariffs, :foreign_key => [:tariff_id, :tariff_start_date]
+ has_one :product_tariff, :foreign_key => [:tariff_id, :tariff_start_date]
+ has_many :products, :through => :product_tariffs, :foreign_key => [:tariff_id, :tariff_start_date]
+end
-flat:\r
- tariff_id: 1\r
- start_date: <%= Date.today.to_s(:db) %>\r
- amount: 50\r
-free:\r
- tariff_id: 2\r
- start_date: <%= Date.today.to_s(:db) %>\r
- amount: 0\r
-flat_future:\r
- tariff_id: 1\r
- start_date: <%= Date.today.next.to_s(:db) %>\r
- amount: 100\r
+flat:
+ tariff_id: 1
+ start_date: <%= Date.today.to_s(:db) %>
+ amount: 50
+free:
+ tariff_id: 2
+ start_date: <%= Date.today.to_s(:db) %>
+ amount: 0
+flat_future:
+ tariff_id: 1
+ start_date: <%= Date.today.next.to_s(:db) %>
+ amount: 100
\ No newline at end of file
-class User < ActiveRecord::Base\r
- has_many :readings\r
- has_many :articles, :through => :readings\r
- has_many :comments, :as => :person\r
- has_many :hacks, :through => :comments, :source => :hack\r
- \r
- def find_custom_articles\r
- articles.find(:all, :conditions => ["name = ?", "Article One"])\r
- end\r
-end\r
+class User < ActiveRecord::Base
+ has_many :readings
+ has_many :articles, :through => :readings
+ has_many :comments, :as => :person
+ has_many :hacks, :through => :comments, :source => :hack
+
+ def find_custom_articles
+ articles.find(:all, :conditions => ["name = ?", "Article One"])
+ end
+end
-santiago:\r
- id: 1\r
- name: Santiago\r
-drnic:\r
- id: 2\r
+santiago:
+ id: 1
+ name: Santiago
+drnic:
+ id: 2
name: Dr Nic
\ No newline at end of file
-# From:\r
-# http://www.bigbold.com/snippets/posts/show/2178\r
-# http://blog.caboo.se/articles/2006/06/11/stupid-hash-tricks\r
-# \r
-# An example utilisation of these methods in a controller is:\r
-# def some_action\r
-# # some script kiddie also passed in :bee, which we don't want tampered with _here_.\r
-# @model = Model.create(params.pass(:foo, :bar))\r
-# end\r
-class Hash\r
-\r
- # lets through the keys in the argument\r
- # >> {:one => 1, :two => 2, :three => 3}.pass(:one)\r
- # => {:one=>1}\r
- def pass(*keys)\r
- keys = keys.first if keys.first.is_a?(Array)\r
- tmp = self.clone\r
- tmp.delete_if {|k,v| ! keys.include?(k.to_sym) }\r
- tmp.delete_if {|k,v| ! keys.include?(k.to_s) }\r
- tmp\r
- end\r
-\r
- # blocks the keys in the arguments\r
- # >> {:one => 1, :two => 2, :three => 3}.block(:one)\r
- # => {:two=>2, :three=>3}\r
- def block(*keys)\r
- keys = keys.first if keys.first.is_a?(Array)\r
- tmp = self.clone\r
- tmp.delete_if {|k,v| keys.include?(k.to_sym) }\r
- tmp.delete_if {|k,v| keys.include?(k.to_s) }\r
- tmp\r
- end\r
-\r
-end\r
+# From:
+# http://www.bigbold.com/snippets/posts/show/2178
+# http://blog.caboo.se/articles/2006/06/11/stupid-hash-tricks
+#
+# An example utilisation of these methods in a controller is:
+# def some_action
+# # some script kiddie also passed in :bee, which we don't want tampered with _here_.
+# @model = Model.create(params.pass(:foo, :bar))
+# end
+class Hash
+
+ # lets through the keys in the argument
+ # >> {:one => 1, :two => 2, :three => 3}.pass(:one)
+ # => {:one=>1}
+ def pass(*keys)
+ keys = keys.first if keys.first.is_a?(Array)
+ tmp = self.clone
+ tmp.delete_if {|k,v| ! keys.include?(k.to_sym) }
+ tmp.delete_if {|k,v| ! keys.include?(k.to_s) }
+ tmp
+ end
+
+ # blocks the keys in the arguments
+ # >> {:one => 1, :two => 2, :three => 3}.block(:one)
+ # => {:two=>2, :three=>3}
+ def block(*keys)
+ keys = keys.first if keys.first.is_a?(Array)
+ tmp = self.clone
+ tmp.delete_if {|k,v| keys.include?(k.to_sym) }
+ tmp.delete_if {|k,v| keys.include?(k.to_s) }
+ tmp
+ end
+
+end
-require 'abstract_unit'\r
-require 'fixtures/article'\r
-require 'fixtures/product'\r
-require 'fixtures/tariff'\r
-require 'fixtures/product_tariff'\r
-require 'fixtures/suburb'\r
-require 'fixtures/street'\r
-require 'fixtures/restaurant'\r
-require 'fixtures/dorm'\r
-require 'fixtures/room'\r
-require 'fixtures/room_attribute'\r
-require 'fixtures/room_attribute_assignment'\r
-require 'fixtures/student'\r
-require 'fixtures/room_assignment'\r
-require 'fixtures/user'\r
-require 'fixtures/reading'\r
-\r
-class TestAssociations < Test::Unit::TestCase\r
- fixtures :articles, :products, :tariffs, :product_tariffs, :suburbs, :streets, :restaurants, :restaurants_suburbs,\r
- :dorms, :rooms, :room_attributes, :room_attribute_assignments, :students, :room_assignments, :users, :readings\r
- \r
- def test_has_many_through_with_conditions_when_through_association_is_not_composite\r
- user = User.find(:first)\r
- assert_equal 1, user.articles.find(:all, :conditions => ["articles.name = ?", "Article One"]).size\r
- end\r
-\r
- def test_has_many_through_with_conditions_when_through_association_is_composite\r
- room = Room.find(:first)\r
- assert_equal 0, room.room_attributes.find(:all, :conditions => ["room_attributes.name != ?", "keg"]).size\r
- end\r
-\r
- def test_has_many_through_on_custom_finder_when_through_association_is_composite_finder_when_through_association_is_not_composite\r
- user = User.find(:first)\r
- assert_equal 1, user.find_custom_articles.size\r
- end\r
-\r
- def test_has_many_through_on_custom_finder_when_through_association_is_composite\r
- room = Room.find(:first)\r
- assert_equal 0, room.find_custom_room_attributes.size\r
- end\r
- \r
- def test_count\r
- assert_equal 2, Product.count(:include => :product_tariffs)\r
- assert_equal 3, Tariff.count(:include => :product_tariffs)\r
- assert_equal 2, Tariff.count(:group => :start_date).size\r
- end\r
- \r
- def test_products\r
- assert_not_nil products(:first_product).product_tariffs\r
- assert_equal 2, products(:first_product).product_tariffs.length\r
- assert_not_nil products(:first_product).tariffs\r
- assert_equal 2, products(:first_product).tariffs.length\r
- assert_not_nil products(:first_product).product_tariff\r
- end\r
- \r
- def test_product_tariffs\r
- assert_not_nil product_tariffs(:first_flat).product\r
- assert_not_nil product_tariffs(:first_flat).tariff\r
- assert_equal Product, product_tariffs(:first_flat).product.class\r
- assert_equal Tariff, product_tariffs(:first_flat).tariff.class\r
- end\r
- \r
- def test_tariffs\r
- assert_not_nil tariffs(:flat).product_tariffs\r
- assert_equal 1, tariffs(:flat).product_tariffs.length\r
- assert_not_nil tariffs(:flat).products\r
- assert_equal 1, tariffs(:flat).products.length\r
- assert_not_nil tariffs(:flat).product_tariff\r
- end\r
- \r
- # Its not generating the instances of associated classes from the rows\r
- def test_find_includes_products\r
- assert @products = Product.find(:all, :include => :product_tariffs)\r
- assert_equal 2, @products.length\r
- assert_not_nil @products.first.instance_variable_get('@product_tariffs'), '@product_tariffs not set; should be array'\r
- assert_equal 3, @products.inject(0) {|sum, tariff| sum + tariff.instance_variable_get('@product_tariffs').length}, \r
- "Incorrect number of product_tariffs returned"\r
- end\r
- \r
- def test_find_includes_tariffs\r
- assert @tariffs = Tariff.find(:all, :include => :product_tariffs)\r
- assert_equal 3, @tariffs.length\r
- assert_not_nil @tariffs.first.instance_variable_get('@product_tariffs'), '@product_tariffs not set; should be array'\r
- assert_equal 3, @tariffs.inject(0) {|sum, tariff| sum + tariff.instance_variable_get('@product_tariffs').length}, \r
- "Incorrect number of product_tariffs returnedturned"\r
- end\r
- \r
- def test_find_includes_product\r
- assert @product_tariffs = ProductTariff.find(:all, :include => :product)\r
- assert_equal 3, @product_tariffs.length\r
- assert_not_nil @product_tariffs.first.instance_variable_get('@product'), '@product not set'\r
- end\r
- \r
- def test_find_includes_comp_belongs_to_tariff\r
- assert @product_tariffs = ProductTariff.find(:all, :include => :tariff)\r
- assert_equal 3, @product_tariffs.length\r
- assert_not_nil @product_tariffs.first.instance_variable_get('@tariff'), '@tariff not set'\r
- end\r
- \r
- def test_find_includes_extended\r
- assert @products = Product.find(:all, :include => {:product_tariffs => :tariff})\r
- assert_equal 3, @products.inject(0) {|sum, product| sum + product.instance_variable_get('@product_tariffs').length},\r
- "Incorrect number of product_tariffs returned"\r
- \r
- assert @tariffs = Tariff.find(:all, :include => {:product_tariffs => :product})\r
- assert_equal 3, @tariffs.inject(0) {|sum, tariff| sum + tariff.instance_variable_get('@product_tariffs').length}, \r
- "Incorrect number of product_tariffs returned"\r
- end\r
- \r
- def test_join_where_clause\r
- @product = Product.find(:first, :include => :product_tariffs)\r
- where_clause = @product.product_tariffs.composite_where_clause(\r
- ['foo','bar'], [1,2]\r
- )\r
- assert_equal('(foo=1 AND bar=2)', where_clause)\r
- end\r
- \r
- def test_has_many_through\r
- @products = Product.find(:all, :include => :tariffs)\r
- assert_equal 3, @products.inject(0) {|sum, product| sum + product.instance_variable_get('@tariffs').length},\r
- "Incorrect number of tariffs returned"\r
- end\r
- \r
- def test_has_many_through_when_not_pre_loaded\r
- student = Student.find(:first)\r
- rooms = student.rooms\r
- assert_equal 1, rooms.size\r
- assert_equal 1, rooms.first.dorm_id\r
- assert_equal 1, rooms.first.room_id\r
- end\r
- \r
- def test_has_many_through_when_through_association_is_composite\r
- dorm = Dorm.find(:first)\r
- assert_equal 1, dorm.rooms.length\r
- assert_equal 1, dorm.rooms.first.room_attributes.length\r
- assert_equal 'keg', dorm.rooms.first.room_attributes.first.name\r
- end\r
-\r
- def test_associations_with_conditions\r
- @suburb = Suburb.find([2, 1])\r
- assert_equal 2, @suburb.streets.size\r
-\r
- @suburb = Suburb.find([2, 1])\r
- assert_equal 1, @suburb.first_streets.size\r
-\r
- @suburb = Suburb.find([2, 1], :include => :streets)\r
- assert_equal 2, @suburb.streets.size\r
-\r
- @suburb = Suburb.find([2, 1], :include => :first_streets)\r
- assert_equal 1, @suburb.first_streets.size\r
- end\r
- \r
- def test_has_and_belongs_to_many\r
- @restaurant = Restaurant.find([1,1])\r
- assert_equal 2, @restaurant.suburbs.size\r
- \r
- @restaurant = Restaurant.find([1,1], :include => :suburbs)\r
- assert_equal 2, @restaurant.suburbs.size \r
- end\r
-end\r
+require 'abstract_unit'
+require 'fixtures/article'
+require 'fixtures/product'
+require 'fixtures/tariff'
+require 'fixtures/product_tariff'
+require 'fixtures/suburb'
+require 'fixtures/street'
+require 'fixtures/restaurant'
+require 'fixtures/dorm'
+require 'fixtures/room'
+require 'fixtures/room_attribute'
+require 'fixtures/room_attribute_assignment'
+require 'fixtures/student'
+require 'fixtures/room_assignment'
+require 'fixtures/user'
+require 'fixtures/reading'
+
+class TestAssociations < Test::Unit::TestCase
+ fixtures :articles, :products, :tariffs, :product_tariffs, :suburbs, :streets, :restaurants, :restaurants_suburbs,
+ :dorms, :rooms, :room_attributes, :room_attribute_assignments, :students, :room_assignments, :users, :readings
+
+ def test_has_many_through_with_conditions_when_through_association_is_not_composite
+ user = User.find(:first)
+ assert_equal 1, user.articles.find(:all, :conditions => ["articles.name = ?", "Article One"]).size
+ end
+
+ def test_has_many_through_with_conditions_when_through_association_is_composite
+ room = Room.find(:first)
+ assert_equal 0, room.room_attributes.find(:all, :conditions => ["room_attributes.name != ?", "keg"]).size
+ end
+
+ def test_has_many_through_on_custom_finder_when_through_association_is_composite_finder_when_through_association_is_not_composite
+ user = User.find(:first)
+ assert_equal 1, user.find_custom_articles.size
+ end
+
+ def test_has_many_through_on_custom_finder_when_through_association_is_composite
+ room = Room.find(:first)
+ assert_equal 0, room.find_custom_room_attributes.size
+ end
+
+ def test_count
+ assert_equal 2, Product.count(:include => :product_tariffs)
+ assert_equal 3, Tariff.count(:include => :product_tariffs)
+ assert_equal 2, Tariff.count(:group => :start_date).size
+ end
+
+ def test_products
+ assert_not_nil products(:first_product).product_tariffs
+ assert_equal 2, products(:first_product).product_tariffs.length
+ assert_not_nil products(:first_product).tariffs
+ assert_equal 2, products(:first_product).tariffs.length
+ assert_not_nil products(:first_product).product_tariff
+ end
+
+ def test_product_tariffs
+ assert_not_nil product_tariffs(:first_flat).product
+ assert_not_nil product_tariffs(:first_flat).tariff
+ assert_equal Product, product_tariffs(:first_flat).product.class
+ assert_equal Tariff, product_tariffs(:first_flat).tariff.class
+ end
+
+ def test_tariffs
+ assert_not_nil tariffs(:flat).product_tariffs
+ assert_equal 1, tariffs(:flat).product_tariffs.length
+ assert_not_nil tariffs(:flat).products
+ assert_equal 1, tariffs(:flat).products.length
+ assert_not_nil tariffs(:flat).product_tariff
+ end
+
+ # Its not generating the instances of associated classes from the rows
+ def test_find_includes_products
+ assert @products = Product.find(:all, :include => :product_tariffs)
+ assert_equal 2, @products.length
+ assert_not_nil @products.first.instance_variable_get('@product_tariffs'), '@product_tariffs not set; should be array'
+ assert_equal 3, @products.inject(0) {|sum, tariff| sum + tariff.instance_variable_get('@product_tariffs').length},
+ "Incorrect number of product_tariffs returned"
+ end
+
+ def test_find_includes_tariffs
+ assert @tariffs = Tariff.find(:all, :include => :product_tariffs)
+ assert_equal 3, @tariffs.length
+ assert_not_nil @tariffs.first.instance_variable_get('@product_tariffs'), '@product_tariffs not set; should be array'
+ assert_equal 3, @tariffs.inject(0) {|sum, tariff| sum + tariff.instance_variable_get('@product_tariffs').length},
+ "Incorrect number of product_tariffs returnedturned"
+ end
+
+ def test_find_includes_product
+ assert @product_tariffs = ProductTariff.find(:all, :include => :product)
+ assert_equal 3, @product_tariffs.length
+ assert_not_nil @product_tariffs.first.instance_variable_get('@product'), '@product not set'
+ end
+
+ def test_find_includes_comp_belongs_to_tariff
+ assert @product_tariffs = ProductTariff.find(:all, :include => :tariff)
+ assert_equal 3, @product_tariffs.length
+ assert_not_nil @product_tariffs.first.instance_variable_get('@tariff'), '@tariff not set'
+ end
+
+ def test_find_includes_extended
+ assert @products = Product.find(:all, :include => {:product_tariffs => :tariff})
+ assert_equal 3, @products.inject(0) {|sum, product| sum + product.instance_variable_get('@product_tariffs').length},
+ "Incorrect number of product_tariffs returned"
+
+ assert @tariffs = Tariff.find(:all, :include => {:product_tariffs => :product})
+ assert_equal 3, @tariffs.inject(0) {|sum, tariff| sum + tariff.instance_variable_get('@product_tariffs').length},
+ "Incorrect number of product_tariffs returned"
+ end
+
+ def test_join_where_clause
+ @product = Product.find(:first, :include => :product_tariffs)
+ where_clause = @product.product_tariffs.composite_where_clause(
+ ['foo','bar'], [1,2]
+ )
+ assert_equal('(foo=1 AND bar=2)', where_clause)
+ end
+
+ def test_has_many_through
+ @products = Product.find(:all, :include => :tariffs)
+ assert_equal 3, @products.inject(0) {|sum, product| sum + product.instance_variable_get('@tariffs').length},
+ "Incorrect number of tariffs returned"
+ end
+
+ def test_has_many_through_when_not_pre_loaded
+ student = Student.find(:first)
+ rooms = student.rooms
+ assert_equal 1, rooms.size
+ assert_equal 1, rooms.first.dorm_id
+ assert_equal 1, rooms.first.room_id
+ end
+
+ def test_has_many_through_when_through_association_is_composite
+ dorm = Dorm.find(:first)
+ assert_equal 1, dorm.rooms.length
+ assert_equal 1, dorm.rooms.first.room_attributes.length
+ assert_equal 'keg', dorm.rooms.first.room_attributes.first.name
+ end
+
+ def test_associations_with_conditions
+ @suburb = Suburb.find([2, 1])
+ assert_equal 2, @suburb.streets.size
+
+ @suburb = Suburb.find([2, 1])
+ assert_equal 1, @suburb.first_streets.size
+
+ @suburb = Suburb.find([2, 1], :include => :streets)
+ assert_equal 2, @suburb.streets.size
+
+ @suburb = Suburb.find([2, 1], :include => :first_streets)
+ assert_equal 1, @suburb.first_streets.size
+ end
+
+ def test_has_and_belongs_to_many
+ @restaurant = Restaurant.find([1,1])
+ assert_equal 2, @restaurant.suburbs.size
+
+ @restaurant = Restaurant.find([1,1], :include => :suburbs)
+ assert_equal 2, @restaurant.suburbs.size
+ end
+end
-require 'abstract_unit'\r
-require 'fixtures/reference_type'\r
-require 'fixtures/reference_code'\r
-\r
-class TestClone < Test::Unit::TestCase\r
- fixtures :reference_types, :reference_codes\r
- \r
- CLASSES = {\r
- :single => {\r
- :class => ReferenceType,\r
- :primary_keys => :reference_type_id,\r
- },\r
- :dual => { \r
- :class => ReferenceCode,\r
- :primary_keys => [:reference_type_id, :reference_code],\r
- },\r
- }\r
- \r
- def setup\r
- self.class.classes = CLASSES\r
- end\r
- \r
- def test_truth\r
- testing_with do\r
- clone = @first.clone\r
- assert_equal @first.attributes.block(@klass.primary_key), clone.attributes\r
- if composite?\r
- @klass.primary_key.each {|key| assert_nil clone[key], "Primary key '#{key}' should be nil"} \r
- else\r
- assert_nil clone[@klass.primary_key], "Sole primary key should be nil"\r
- end\r
- end\r
- end\r
+require 'abstract_unit'
+require 'fixtures/reference_type'
+require 'fixtures/reference_code'
+
+class TestClone < Test::Unit::TestCase
+ fixtures :reference_types, :reference_codes
+
+ CLASSES = {
+ :single => {
+ :class => ReferenceType,
+ :primary_keys => :reference_type_id,
+ },
+ :dual => {
+ :class => ReferenceCode,
+ :primary_keys => [:reference_type_id, :reference_code],
+ },
+ }
+
+ def setup
+ self.class.classes = CLASSES
+ end
+
+ def test_truth
+ testing_with do
+ clone = @first.clone
+ assert_equal @first.attributes.block(@klass.primary_key), clone.attributes
+ if composite?
+ @klass.primary_key.each {|key| assert_nil clone[key], "Primary key '#{key}' should be nil"}
+ else
+ assert_nil clone[@klass.primary_key], "Sole primary key should be nil"
+ end
+ end
+ end
end
\ No newline at end of file
-require 'abstract_unit'\r
-require 'fixtures/reference_type'\r
-require 'fixtures/reference_code'\r
-require 'fixtures/department'\r
-require 'fixtures/employee'\r
-\r
-class TestDelete < Test::Unit::TestCase\r
- fixtures :reference_types, :reference_codes, :departments, :employees\r
- \r
- CLASSES = {\r
- :single => {\r
- :class => ReferenceType,\r
- :primary_keys => :reference_type_id,\r
- },\r
- :dual => { \r
- :class => ReferenceCode,\r
- :primary_keys => [:reference_type_id, :reference_code],\r
- },\r
- }\r
- \r
- def setup\r
- self.class.classes = CLASSES\r
- end\r
- \r
- def test_destroy_one\r
- testing_with do\r
- #assert @first.destroy\r
- assert true\r
- end\r
- end\r
- \r
- def test_destroy_one_via_class\r
- testing_with do\r
- assert @klass.destroy(*@first.id)\r
- end\r
- end\r
- \r
- def test_destroy_one_alone_via_class\r
- testing_with do\r
- assert @klass.destroy(@first.id)\r
- end\r
- end\r
- \r
- def test_delete_one\r
- testing_with do\r
- assert @klass.delete(*@first.id) if composite?\r
- end\r
- end\r
- \r
- def test_delete_one_alone\r
- testing_with do\r
- assert @klass.delete(@first.id)\r
- end\r
- end\r
- \r
- def test_delete_many\r
- testing_with do\r
- to_delete = @klass.find(:all)[0..1]\r
- assert_equal 2, to_delete.length\r
- end\r
- end\r
- \r
- def test_delete_all\r
- testing_with do\r
- @klass.delete_all\r
- end\r
- end\r
-\r
- def test_clear_association\r
- department = Department.find(1,1)\r
- assert_equal 2, department.employees.size, "Before clear employee count should be 2."\r
- department.employees.clear\r
- assert_equal 0, department.employees.size, "After clear employee count should be 0."\r
- department.reload\r
- assert_equal 0, department.employees.size, "After clear and a reload from DB employee count should be 0."\r
- end\r
-\r
- def test_delete_association\r
- department = Department.find(1,1)\r
- assert_equal 2, department.employees.size , "Before delete employee count should be 2."\r
- first_employee = department.employees[0]\r
- department.employees.delete(first_employee)\r
- assert_equal 1, department.employees.size, "After delete employee count should be 1."\r
- department.reload\r
- assert_equal 1, department.employees.size, "After delete and a reload from DB employee count should be 1."\r
- end\r
-\r
- def test_delete_records_for_has_many_association_with_composite_primary_key\r
- reference_type = ReferenceType.find(1)\r
- codes_to_delete = reference_type.reference_codes[0..1]\r
- assert_equal 3, reference_type.reference_codes.size, "Before deleting records reference_code count should be 3."\r
- reference_type.reference_codes.delete_records(codes_to_delete)\r
- reference_type.reload\r
- assert_equal 1, reference_type.reference_codes.size, "After deleting 2 records and a reload from DB reference_code count should be 1."\r
- end\r
-end\r
+require 'abstract_unit'
+require 'fixtures/reference_type'
+require 'fixtures/reference_code'
+require 'fixtures/department'
+require 'fixtures/employee'
+
+class TestDelete < Test::Unit::TestCase
+ fixtures :reference_types, :reference_codes, :departments, :employees
+
+ CLASSES = {
+ :single => {
+ :class => ReferenceType,
+ :primary_keys => :reference_type_id,
+ },
+ :dual => {
+ :class => ReferenceCode,
+ :primary_keys => [:reference_type_id, :reference_code],
+ },
+ }
+
+ def setup
+ self.class.classes = CLASSES
+ end
+
+ def test_destroy_one
+ testing_with do
+ #assert @first.destroy
+ assert true
+ end
+ end
+
+ def test_destroy_one_via_class
+ testing_with do
+ assert @klass.destroy(*@first.id)
+ end
+ end
+
+ def test_destroy_one_alone_via_class
+ testing_with do
+ assert @klass.destroy(@first.id)
+ end
+ end
+
+ def test_delete_one
+ testing_with do
+ assert @klass.delete(*@first.id) if composite?
+ end
+ end
+
+ def test_delete_one_alone
+ testing_with do
+ assert @klass.delete(@first.id)
+ end
+ end
+
+ def test_delete_many
+ testing_with do
+ to_delete = @klass.find(:all)[0..1]
+ assert_equal 2, to_delete.length
+ end
+ end
+
+ def test_delete_all
+ testing_with do
+ @klass.delete_all
+ end
+ end
+
+ def test_clear_association
+ department = Department.find(1,1)
+ assert_equal 2, department.employees.size, "Before clear employee count should be 2."
+ department.employees.clear
+ assert_equal 0, department.employees.size, "After clear employee count should be 0."
+ department.reload
+ assert_equal 0, department.employees.size, "After clear and a reload from DB employee count should be 0."
+ end
+
+ def test_delete_association
+ department = Department.find(1,1)
+ assert_equal 2, department.employees.size , "Before delete employee count should be 2."
+ first_employee = department.employees[0]
+ department.employees.delete(first_employee)
+ assert_equal 1, department.employees.size, "After delete employee count should be 1."
+ department.reload
+ assert_equal 1, department.employees.size, "After delete and a reload from DB employee count should be 1."
+ end
+
+ def test_delete_records_for_has_many_association_with_composite_primary_key
+ reference_type = ReferenceType.find(1)
+ codes_to_delete = reference_type.reference_codes[0..1]
+ assert_equal 3, reference_type.reference_codes.size, "Before deleting records reference_code count should be 3."
+ reference_type.reference_codes.delete_records(codes_to_delete)
+ reference_type.reload
+ assert_equal 1, reference_type.reference_codes.size, "After deleting 2 records and a reload from DB reference_code count should be 1."
+ end
+end
-require 'abstract_unit'\r
-require 'fixtures/reference_type'\r
-require 'fixtures/reference_code'\r
-\r
-class TestDummy < Test::Unit::TestCase\r
- fixtures :reference_types, :reference_codes\r
- \r
- classes = {\r
- :single => {\r
- :class => ReferenceType,\r
- :primary_keys => :reference_type_id,\r
- },\r
- :dual => { \r
- :class => ReferenceCode,\r
- :primary_keys => [:reference_type_id, :reference_code],\r
- },\r
- }\r
- \r
- def setup\r
- self.class.classes = classes\r
- end\r
- \r
- def test_truth\r
- testing_with do\r
- assert true\r
- end\r
- end\r
+require 'abstract_unit'
+require 'fixtures/reference_type'
+require 'fixtures/reference_code'
+
+class TestDummy < Test::Unit::TestCase
+ fixtures :reference_types, :reference_codes
+
+ classes = {
+ :single => {
+ :class => ReferenceType,
+ :primary_keys => :reference_type_id,
+ },
+ :dual => {
+ :class => ReferenceCode,
+ :primary_keys => [:reference_type_id, :reference_code],
+ },
+ }
+
+ def setup
+ self.class.classes = classes
+ end
+
+ def test_truth
+ testing_with do
+ assert true
+ end
+ end
end
\ No newline at end of file
-require 'abstract_unit'\r
-require 'fixtures/reference_type'\r
-require 'fixtures/reference_code'\r
-\r
-# Testing the find action on composite ActiveRecords with two primary keys\r
-class TestFind < Test::Unit::TestCase\r
- fixtures :reference_types, :reference_codes\r
- \r
- CLASSES = {\r
- :single => {\r
- :class => ReferenceType,\r
- :primary_keys => [:reference_type_id],\r
- },\r
- :dual => { \r
- :class => ReferenceCode,\r
- :primary_keys => [:reference_type_id, :reference_code],\r
- },\r
- :dual_strs => { \r
- :class => ReferenceCode,\r
- :primary_keys => ['reference_type_id', 'reference_code'],\r
- },\r
- }\r
- \r
- def setup\r
- self.class.classes = CLASSES\r
- end\r
- \r
- def test_find_first\r
- testing_with do\r
- obj = @klass.find(:first)\r
- assert obj\r
- assert_equal @klass, obj.class\r
- end\r
- end\r
- \r
- def test_find\r
- testing_with do\r
- found = @klass.find(*first_id) # e.g. find(1,1) or find 1,1\r
- assert found\r
- assert_equal @klass, found.class\r
- assert_equal found, @klass.find(found.id)\r
- assert_equal found, @klass.find(found.to_param)\r
- end\r
- end\r
- \r
- def test_find_composite_ids\r
- testing_with do\r
- found = @klass.find(first_id) # e.g. find([1,1].to_composite_ids)\r
- assert found\r
- assert_equal @klass, found.class\r
- assert_equal found, @klass.find(found.id)\r
- assert_equal found, @klass.find(found.to_param)\r
- end\r
- end\r
- \r
- def test_to_param\r
- testing_with do\r
- assert_equal first_id_str, @first.to_param.to_s\r
- end\r
- end\r
- \r
- def things_to_look_at\r
- testing_with do\r
- assert_equal found, @klass.find(found.id.to_s) # fails for 2+ keys\r
- end\r
- end\r
- \r
- def test_not_found\r
- assert_raise(::ActiveRecord::RecordNotFound) do\r
- ReferenceCode.send :find, '999,999'\r
- end\r
- end\r
+require 'abstract_unit'
+require 'fixtures/reference_type'
+require 'fixtures/reference_code'
+
+# Testing the find action on composite ActiveRecords with two primary keys
+class TestFind < Test::Unit::TestCase
+ fixtures :reference_types, :reference_codes
+
+ CLASSES = {
+ :single => {
+ :class => ReferenceType,
+ :primary_keys => [:reference_type_id],
+ },
+ :dual => {
+ :class => ReferenceCode,
+ :primary_keys => [:reference_type_id, :reference_code],
+ },
+ :dual_strs => {
+ :class => ReferenceCode,
+ :primary_keys => ['reference_type_id', 'reference_code'],
+ },
+ }
+
+ def setup
+ self.class.classes = CLASSES
+ end
+
+ def test_find_first
+ testing_with do
+ obj = @klass.find(:first)
+ assert obj
+ assert_equal @klass, obj.class
+ end
+ end
+
+ def test_find
+ testing_with do
+ found = @klass.find(*first_id) # e.g. find(1,1) or find 1,1
+ assert found
+ assert_equal @klass, found.class
+ assert_equal found, @klass.find(found.id)
+ assert_equal found, @klass.find(found.to_param)
+ end
+ end
+
+ def test_find_composite_ids
+ testing_with do
+ found = @klass.find(first_id) # e.g. find([1,1].to_composite_ids)
+ assert found
+ assert_equal @klass, found.class
+ assert_equal found, @klass.find(found.id)
+ assert_equal found, @klass.find(found.to_param)
+ end
+ end
+
+ def test_to_param
+ testing_with do
+ assert_equal first_id_str, @first.to_param.to_s
+ end
+ end
+
+ def things_to_look_at
+ testing_with do
+ assert_equal found, @klass.find(found.id.to_s) # fails for 2+ keys
+ end
+ end
+
+ def test_not_found
+ assert_raise(::ActiveRecord::RecordNotFound) do
+ ReferenceCode.send :find, '999,999'
+ end
+ end
end
\ No newline at end of file
-require 'abstract_unit'\r
-require 'fixtures/reference_type'\r
-require 'fixtures/reference_code'\r
-\r
-class TestIds < Test::Unit::TestCase\r
- fixtures :reference_types, :reference_codes\r
- \r
- CLASSES = {\r
- :single => {\r
- :class => ReferenceType,\r
- :primary_keys => [:reference_type_id],\r
- },\r
- :dual => { \r
- :class => ReferenceCode,\r
- :primary_keys => [:reference_type_id, :reference_code],\r
- },\r
- :dual_strs => { \r
- :class => ReferenceCode,\r
- :primary_keys => ['reference_type_id', 'reference_code'],\r
- },\r
- }\r
- \r
- def setup\r
- self.class.classes = CLASSES\r
- end\r
- \r
- def test_id\r
- testing_with do\r
- assert_equal @first.id, @first.ids if composite?\r
- end\r
- end\r
- \r
- def test_id_to_s\r
- testing_with do\r
- assert_equal first_id_str, @first.id.to_s\r
- assert_equal first_id_str, "#{@first.id}"\r
- end\r
- end\r
- \r
- def test_ids_to_s\r
- testing_with do\r
- order = @klass.primary_key.is_a?(String) ? @klass.primary_key : @klass.primary_key.join(',')\r
- to_test = @klass.find(:all, :order => order)[0..1].map(&:id)\r
- assert_equal '(1,1),(1,2)', @klass.ids_to_s(to_test) if @key_test == :dual\r
- assert_equal '1,1;1,2', @klass.ids_to_s(to_test, ',', ';', '', '') if @key_test == :dual\r
- end\r
- end\r
- \r
- def test_composite_where_clause\r
- testing_with do\r
- where = 'reference_codes.reference_type_id=1 AND reference_codes.reference_code=2) OR (reference_codes.reference_type_id=2 AND reference_codes.reference_code=2'\r
- assert_equal(where, @klass.composite_where_clause([[1, 2], [2, 2]])) if @key_test == :dual\r
- end\r
- end\r
- \r
- def test_set_ids_string\r
- testing_with do\r
- array = @primary_keys.collect {|key| 5}\r
- expected = composite? ? array.to_composite_keys : array.first\r
- @first.id = expected.to_s\r
- assert_equal expected, @first.id\r
- end\r
- end\r
- \r
- def test_set_ids_array\r
- testing_with do\r
- array = @primary_keys.collect {|key| 5}\r
- expected = composite? ? array.to_composite_keys : array.first\r
- @first.id = expected\r
- assert_equal expected, @first.id\r
- end\r
- end\r
- \r
- def test_set_ids_comp\r
- testing_with do\r
- array = @primary_keys.collect {|key| 5}\r
- expected = composite? ? array.to_composite_keys : array.first\r
- @first.id = expected\r
- assert_equal expected, @first.id\r
- end\r
- end\r
- \r
- def test_primary_keys\r
- testing_with do\r
- if composite?\r
- assert_not_nil @klass.primary_keys\r
- assert_equal @primary_keys.map {|key| key.to_sym}, @klass.primary_keys\r
- assert_equal @klass.primary_keys, @klass.primary_key\r
- else\r
- assert_not_nil @klass.primary_key\r
- assert_equal @primary_keys, [@klass.primary_key.to_sym]\r
- end\r
- assert_equal @primary_keys.join(','), @klass.primary_key.to_s\r
- # Need a :primary_keys should be Array with to_s overridden\r
- end\r
- end\r
+require 'abstract_unit'
+require 'fixtures/reference_type'
+require 'fixtures/reference_code'
+
+class TestIds < Test::Unit::TestCase
+ fixtures :reference_types, :reference_codes
+
+ CLASSES = {
+ :single => {
+ :class => ReferenceType,
+ :primary_keys => [:reference_type_id],
+ },
+ :dual => {
+ :class => ReferenceCode,
+ :primary_keys => [:reference_type_id, :reference_code],
+ },
+ :dual_strs => {
+ :class => ReferenceCode,
+ :primary_keys => ['reference_type_id', 'reference_code'],
+ },
+ }
+
+ def setup
+ self.class.classes = CLASSES
+ end
+
+ def test_id
+ testing_with do
+ assert_equal @first.id, @first.ids if composite?
+ end
+ end
+
+ def test_id_to_s
+ testing_with do
+ assert_equal first_id_str, @first.id.to_s
+ assert_equal first_id_str, "#{@first.id}"
+ end
+ end
+
+ def test_ids_to_s
+ testing_with do
+ order = @klass.primary_key.is_a?(String) ? @klass.primary_key : @klass.primary_key.join(',')
+ to_test = @klass.find(:all, :order => order)[0..1].map(&:id)
+ assert_equal '(1,1),(1,2)', @klass.ids_to_s(to_test) if @key_test == :dual
+ assert_equal '1,1;1,2', @klass.ids_to_s(to_test, ',', ';', '', '') if @key_test == :dual
+ end
+ end
+
+ def test_composite_where_clause
+ testing_with do
+ where = 'reference_codes.reference_type_id=1 AND reference_codes.reference_code=2) OR (reference_codes.reference_type_id=2 AND reference_codes.reference_code=2'
+ assert_equal(where, @klass.composite_where_clause([[1, 2], [2, 2]])) if @key_test == :dual
+ end
+ end
+
+ def test_set_ids_string
+ testing_with do
+ array = @primary_keys.collect {|key| 5}
+ expected = composite? ? array.to_composite_keys : array.first
+ @first.id = expected.to_s
+ assert_equal expected, @first.id
+ end
+ end
+
+ def test_set_ids_array
+ testing_with do
+ array = @primary_keys.collect {|key| 5}
+ expected = composite? ? array.to_composite_keys : array.first
+ @first.id = expected
+ assert_equal expected, @first.id
+ end
+ end
+
+ def test_set_ids_comp
+ testing_with do
+ array = @primary_keys.collect {|key| 5}
+ expected = composite? ? array.to_composite_keys : array.first
+ @first.id = expected
+ assert_equal expected, @first.id
+ end
+ end
+
+ def test_primary_keys
+ testing_with do
+ if composite?
+ assert_not_nil @klass.primary_keys
+ assert_equal @primary_keys.map {|key| key.to_sym}, @klass.primary_keys
+ assert_equal @klass.primary_keys, @klass.primary_key
+ else
+ assert_not_nil @klass.primary_key
+ assert_equal @primary_keys, [@klass.primary_key.to_sym]
+ end
+ assert_equal @primary_keys.join(','), @klass.primary_key.to_s
+ # Need a :primary_keys should be Array with to_s overridden
+ end
+ end
end
\ No newline at end of file
-require 'abstract_unit'\r
-require 'fixtures/reference_type'\r
-require 'fixtures/reference_code'\r
-\r
-class TestMiscellaneous < Test::Unit::TestCase\r
- fixtures :reference_types, :reference_codes, :products\r
- \r
- CLASSES = {\r
- :single => {\r
- :class => ReferenceType,\r
- :primary_keys => :reference_type_id,\r
- },\r
- :dual => { \r
- :class => ReferenceCode,\r
- :primary_keys => [:reference_type_id, :reference_code],\r
- },\r
- }\r
- \r
- def setup\r
- self.class.classes = CLASSES\r
- end\r
-\r
- def test_composite_class\r
- testing_with do\r
- assert_equal composite?, @klass.composite?\r
- end\r
- end\r
-\r
- def test_composite_instance\r
- testing_with do\r
- assert_equal composite?, @first.composite?\r
- end\r
- end\r
- \r
- def test_count\r
- assert_equal 2, Product.count\r
- end\r
- \r
+require 'abstract_unit'
+require 'fixtures/reference_type'
+require 'fixtures/reference_code'
+
+class TestMiscellaneous < Test::Unit::TestCase
+ fixtures :reference_types, :reference_codes, :products
+
+ CLASSES = {
+ :single => {
+ :class => ReferenceType,
+ :primary_keys => :reference_type_id,
+ },
+ :dual => {
+ :class => ReferenceCode,
+ :primary_keys => [:reference_type_id, :reference_code],
+ },
+ }
+
+ def setup
+ self.class.classes = CLASSES
+ end
+
+ def test_composite_class
+ testing_with do
+ assert_equal composite?, @klass.composite?
+ end
+ end
+
+ def test_composite_instance
+ testing_with do
+ assert_equal composite?, @first.composite?
+ end
+ end
+
+ def test_count
+ assert_equal 2, Product.count
+ end
+
end
\ No newline at end of file
-require 'abstract_unit'\r
-require 'fixtures/reference_type'\r
-require 'fixtures/reference_code'\r
-require 'plugins/pagination'\r
-\r
-class TestPagination < Test::Unit::TestCase\r
- fixtures :reference_types, :reference_codes\r
- \r
- include ActionController::Pagination\r
- DEFAULT_PAGE_SIZE = 2\r
- \r
- attr_accessor :params\r
- \r
- CLASSES = {\r
- :single => {\r
- :class => ReferenceType,\r
- :primary_keys => :reference_type_id,\r
- :table => :reference_types,\r
- },\r
- :dual => { \r
- :class => ReferenceCode,\r
- :primary_keys => [:reference_type_id, :reference_code],\r
- :table => :reference_codes,\r
- },\r
- }\r
- \r
- def setup\r
- self.class.classes = CLASSES\r
- @params = {}\r
- end\r
-\r
- def test_paginate_all\r
- testing_with do\r
- @object_pages, @objects = paginate @klass_info[:table], :per_page => DEFAULT_PAGE_SIZE\r
- assert_equal 2, @objects.length, "Each page should have #{DEFAULT_PAGE_SIZE} items"\r
- end\r
- end\r
+require 'abstract_unit'
+require 'fixtures/reference_type'
+require 'fixtures/reference_code'
+require 'plugins/pagination'
+
+class TestPagination < Test::Unit::TestCase
+ fixtures :reference_types, :reference_codes
+
+ include ActionController::Pagination
+ DEFAULT_PAGE_SIZE = 2
+
+ attr_accessor :params
+
+ CLASSES = {
+ :single => {
+ :class => ReferenceType,
+ :primary_keys => :reference_type_id,
+ :table => :reference_types,
+ },
+ :dual => {
+ :class => ReferenceCode,
+ :primary_keys => [:reference_type_id, :reference_code],
+ :table => :reference_codes,
+ },
+ }
+
+ def setup
+ self.class.classes = CLASSES
+ @params = {}
+ end
+
+ def test_paginate_all
+ testing_with do
+ @object_pages, @objects = paginate @klass_info[:table], :per_page => DEFAULT_PAGE_SIZE
+ assert_equal 2, @objects.length, "Each page should have #{DEFAULT_PAGE_SIZE} items"
+ end
+ end
end
\ No newline at end of file
-# Test cases devised by Santiago that broke the Composite Primary Keys\r
-# code at one point in time. But no more!!!\r
-\r
-require 'abstract_unit'\r
-require 'fixtures/user'\r
-require 'fixtures/article'\r
-require 'fixtures/reading'\r
-\r
-class TestSantiago < Test::Unit::TestCase\r
- fixtures :suburbs, :streets, :users, :articles, :readings\r
- \r
- def test_normal_and_composite_associations\r
- assert_not_nil @suburb = Suburb.find(1,1)\r
- assert_equal 1, @suburb.streets.length\r
- \r
- assert_not_nil @street = Street.find(1)\r
- assert_not_nil @street.suburb\r
- end\r
- \r
- def test_single_keys\r
- @santiago = User.find(1)\r
- assert_not_nil @santiago.articles\r
- assert_equal 2, @santiago.articles.length\r
- assert_not_nil @santiago.readings\r
- assert_equal 2, @santiago.readings.length\r
- end\r
-end\r
+# Test cases devised by Santiago that broke the Composite Primary Keys
+# code at one point in time. But no more!!!
+
+require 'abstract_unit'
+require 'fixtures/user'
+require 'fixtures/article'
+require 'fixtures/reading'
+
+class TestSantiago < Test::Unit::TestCase
+ fixtures :suburbs, :streets, :users, :articles, :readings
+
+ def test_normal_and_composite_associations
+ assert_not_nil @suburb = Suburb.find(1,1)
+ assert_equal 1, @suburb.streets.length
+
+ assert_not_nil @street = Street.find(1)
+ assert_not_nil @street.suburb
+ end
+
+ def test_single_keys
+ @santiago = User.find(1)
+ assert_not_nil @santiago.articles
+ assert_equal 2, @santiago.articles.length
+ assert_not_nil @santiago.readings
+ assert_equal 2, @santiago.readings.length
+ end
+end
-require 'abstract_unit'\r
-require 'fixtures/reference_type'\r
-require 'fixtures/reference_code'\r
-\r
-class TestUpdate < Test::Unit::TestCase\r
- fixtures :reference_types, :reference_codes\r
- \r
- CLASSES = {\r
- :single => {\r
- :class => ReferenceType,\r
- :primary_keys => :reference_type_id,\r
- :update => { :description => 'RT Desc' },\r
- },\r
- :dual => { \r
- :class => ReferenceCode,\r
- :primary_keys => [:reference_type_id, :reference_code],\r
- :update => { :description => 'RT Desc' },\r
- },\r
- }\r
- \r
- def setup\r
- self.class.classes = CLASSES\r
- end\r
- \r
- def test_setup\r
- testing_with do\r
- assert_not_nil @klass_info[:update]\r
- end\r
- end\r
- \r
- def test_update_attributes\r
- testing_with do\r
- assert @first.update_attributes(@klass_info[:update])\r
- assert @first.reload\r
- @klass_info[:update].each_pair do |attr_name, new_value|\r
- assert_equal new_value, @first[attr_name], "Attribute #{attr_name} is incorrect"\r
- end\r
- end\r
- end\r
+require 'abstract_unit'
+require 'fixtures/reference_type'
+require 'fixtures/reference_code'
+
+class TestUpdate < Test::Unit::TestCase
+ fixtures :reference_types, :reference_codes
+
+ CLASSES = {
+ :single => {
+ :class => ReferenceType,
+ :primary_keys => :reference_type_id,
+ :update => { :description => 'RT Desc' },
+ },
+ :dual => {
+ :class => ReferenceCode,
+ :primary_keys => [:reference_type_id, :reference_code],
+ :update => { :description => 'RT Desc' },
+ },
+ }
+
+ def setup
+ self.class.classes = CLASSES
+ end
+
+ def test_setup
+ testing_with do
+ assert_not_nil @klass_info[:update]
+ end
+ end
+
+ def test_update_attributes
+ testing_with do
+ assert @first.update_attributes(@klass_info[:update])
+ assert @first.reload
+ @klass_info[:update].each_pair do |attr_name, new_value|
+ assert_equal new_value, @first[attr_name], "Attribute #{attr_name} is incorrect"
+ end
+ end
+ end
end
\ No newline at end of file
-body {\r
- background-color: #2F30EE;\r
- font-family: "Georgia", sans-serif;\r
- font-size: 16px;\r
- line-height: 1.6em;\r
- padding: 1.6em 0 0 0;\r
- color: #eee;\r
-}\r
-h1, h2, h3, h4, h5, h6 {\r
- color: #FFEDFA;\r
-}\r
-h1 { \r
- font-family: sans-serif;\r
- font-weight: normal;\r
- font-size: 4em;\r
- line-height: 0.8em;\r
- letter-spacing: -0.1ex;\r
- margin: 5px;\r
-}\r
-li {\r
- padding: 0;\r
- margin: 0;\r
- list-style-type: square;\r
-}\r
-a {\r
- color: #99f;\r
- font-weight: normal;\r
- text-decoration: underline;\r
-}\r
-blockquote {\r
- font-size: 90%;\r
- font-style: italic;\r
- border-left: 1px solid #eee;\r
- padding-left: 1em;\r
-}\r
-.caps {\r
- font-size: 80%;\r
-}\r
-\r
-#main {\r
- width: 45em;\r
- padding: 0;\r
- margin: 0 auto;\r
-}\r
-.coda {\r
- text-align: right;\r
- color: #77f;\r
- font-size: smaller;\r
-}\r
-\r
-table {\r
- font-size: 90%;\r
- line-height: 1.4em;\r
- color: #ff8;\r
- background-color: #111;\r
- padding: 2px 10px 2px 10px;\r
- border-style: dashed;\r
-}\r
-\r
-th {\r
- color: #fff;\r
-}\r
-\r
-td {\r
- padding: 2px 10px 2px 10px;\r
-}\r
-\r
-.success {\r
- color: #0CC52B;\r
-}\r
-\r
-.failed {\r
- color: #E90A1B;\r
-}\r
-\r
-.unknown {\r
- color: #995000;\r
-}\r
-pre, code {\r
- font-family: monospace;\r
- font-size: 90%;\r
- line-height: 1.4em;\r
- color: #ff8;\r
- background-color: #111;\r
- padding: 2px 10px 2px 10px;\r
-}\r
-.comment { color: #aaa; font-style: italic; }\r
-.keyword { color: #eff; font-weight: bold; }\r
-.punct { color: #eee; font-weight: bold; }\r
-.symbol { color: #0bb; }\r
-.string { color: #6b4; }\r
-.ident { color: #ff8; }\r
-.constant { color: #66f; }\r
-.regex { color: #ec6; }\r
-.number { color: #F99; }\r
-.expr { color: #227; }\r
-\r
-#version {\r
- float: right;\r
- text-align: right;\r
- font-family: sans-serif;\r
- font-weight: normal;\r
- background-color: #ff8;\r
- color: #66f;\r
- padding: 15px 20px 10px 20px;\r
- margin: 0 auto;\r
- margin-top: 15px;\r
- border: 3px solid #66f;\r
-}\r
-\r
-#version .numbers {\r
- display: block;\r
- font-size: 4em;\r
- line-height: 0.8em;\r
- letter-spacing: -0.1ex;\r
-}\r
-\r
-#version a {\r
- text-decoration: none;\r
-}\r
-\r
-.clickable {\r
- cursor: pointer; \r
- cursor: hand;\r
-}\r
-\r
+body {
+ background-color: #2F30EE;
+ font-family: "Georgia", sans-serif;
+ font-size: 16px;
+ line-height: 1.6em;
+ padding: 1.6em 0 0 0;
+ color: #eee;
+}
+h1, h2, h3, h4, h5, h6 {
+ color: #FFEDFA;
+}
+h1 {
+ font-family: sans-serif;
+ font-weight: normal;
+ font-size: 4em;
+ line-height: 0.8em;
+ letter-spacing: -0.1ex;
+ margin: 5px;
+}
+li {
+ padding: 0;
+ margin: 0;
+ list-style-type: square;
+}
+a {
+ color: #99f;
+ font-weight: normal;
+ text-decoration: underline;
+}
+blockquote {
+ font-size: 90%;
+ font-style: italic;
+ border-left: 1px solid #eee;
+ padding-left: 1em;
+}
+.caps {
+ font-size: 80%;
+}
+
+#main {
+ width: 45em;
+ padding: 0;
+ margin: 0 auto;
+}
+.coda {
+ text-align: right;
+ color: #77f;
+ font-size: smaller;
+}
+
+table {
+ font-size: 90%;
+ line-height: 1.4em;
+ color: #ff8;
+ background-color: #111;
+ padding: 2px 10px 2px 10px;
+ border-style: dashed;
+}
+
+th {
+ color: #fff;
+}
+
+td {
+ padding: 2px 10px 2px 10px;
+}
+
+.success {
+ color: #0CC52B;
+}
+
+.failed {
+ color: #E90A1B;
+}
+
+.unknown {
+ color: #995000;
+}
+pre, code {
+ font-family: monospace;
+ font-size: 90%;
+ line-height: 1.4em;
+ color: #ff8;
+ background-color: #111;
+ padding: 2px 10px 2px 10px;
+}
+.comment { color: #aaa; font-style: italic; }
+.keyword { color: #eff; font-weight: bold; }
+.punct { color: #eee; font-weight: bold; }
+.symbol { color: #0bb; }
+.string { color: #6b4; }
+.ident { color: #ff8; }
+.constant { color: #66f; }
+.regex { color: #ec6; }
+.number { color: #F99; }
+.expr { color: #227; }
+
+#version {
+ float: right;
+ text-align: right;
+ font-family: sans-serif;
+ font-weight: normal;
+ background-color: #ff8;
+ color: #66f;
+ padding: 15px 20px 10px 20px;
+ margin: 0 auto;
+ margin-top: 15px;
+ border: 3px solid #66f;
+}
+
+#version .numbers {
+ display: block;
+ font-size: 4em;
+ line-height: 0.8em;
+ letter-spacing: -0.1ex;
+}
+
+#version a {
+ text-decoration: none;
+}
+
+.clickable {
+ cursor: pointer;
+ cursor: hand;
+}
+
-h1. Announcement JS file\r
+h1. Announcement JS file
MagicAnnouncement.show('compositekeys', version);
\ No newline at end of file
// Version JS file
var version = "2.2.2";
-\r
+
document.write(" - " + version);
-h1. Version JS file\r
-\r
+h1. Version JS file
+
document.write(" - " + version);
\ No newline at end of file
-# Lower Sorbian translations for Ruby on Rails\r
-# by Michael Wolf (preklady@wolfmicha.de)\r
-\r
-dsb:\r
- # ActiveSupport\r
- support:\r
- array:\r
- words_connector: ", "\r
- two_words_connector: " a "\r
- last_word_connector: " a "\r
- sentence_connector: "a"\r
- skip_last_comma: true\r
-\r
- # Date\r
- date:\r
- formats:\r
- default: "%d. %m. %Y"\r
- short: "%d %b"\r
- long: "%d. %B %Y"\r
- day_names: [njeźela, pónjeźele, wałtora, srjoda, stwórtk, pětk, sobota]\r
- abbr_day_names: [Nj, Pó, Wu, Sr, St, Pě, So]\r
- month_names: [~, Januar, Februar, Měrc, Apryl, Maj, Junij, Julij, Awgust, September, Oktober, Nowember, December]\r
- abbr_month_names: [~, jan, feb, měr, apr, maj, jun, jul, awg, sep, okt, now, dec]\r
- order: [:day, :month, :year]\r
-\r
- # Time\r
- time:\r
- formats:\r
- default: "%A, %d. %B %Y, %H:%M hodź"\r
- short: "%d. %B, %H:%M hodź."\r
- long: "%A, %d. %B %Y, %H:%M hodź."\r
- am: "dopołdnja"\r
- pm: "wótpołdnja"\r
-\r
-\r
- # Numbers\r
- number:\r
- format:\r
- precision: 3\r
- separator: ","\r
- delimiter: "."\r
- currency:\r
- format:\r
- unit: "€"\r
- precision: 2\r
- format: "%n %u"\r
- separator: ","\r
- delimiter: " "\r
- human:\r
- format:\r
- precision: 1\r
- delimiter: ""\r
- storage_units:\r
- format: "%n %u"\r
- units:\r
- byte:\r
- one: "bajt"\r
- two: "bajta"\r
- few: "bajty"\r
- other: "bajtow"\r
- kb: "KB"\r
- mb: "MB"\r
- gb: "GB"\r
- tb: "TB"\r
-\r
- percentage:\r
- format:\r
- delimiter: ""\r
-\r
- precision:\r
- format:\r
- delimiter: ""\r
-\r
-\r
- # Distance of time ... helper\r
- # Used in distance_of_time_in_words(), distance_of_time_in_words_to_now(), time_ago_in_words()\r
- datetime:\r
- distance_in_words:\r
- half_a_minute: "poł minuty"\r
- less_than_x_seconds:\r
- one: "mjenjej ako 1 sekundu"\r
- two: "mjenjej ako {{count}} sekundoma"\r
- few: "mjenjej ako {{count}} sekundami"\r
- other: "mjenjej ako {{count}} sekundami"\r
- x_seconds:\r
- one: "1 sekundu"\r
- two: "{{count}} sekundoma"\r
- few: "{{count}} sekundami"\r
- other: "{{count}} sekundami"\r
- less_than_x_minutes:\r
- one: "mjenjej ako 1 minutu"\r
- two: "mjenjej ako {{count}} minutoma"\r
- few: "mjenjej ako {{count}} minutami"\r
- other: "mjenjej ako {{count}} minutami"\r
- x_minutes:\r
- one: "1 minutu"\r
- two: "{{count}} minutoma"\r
- few: "{{count}} minutami"\r
- other: "{{count}} minutami"\r
- about_x_hours:\r
- one: "něźi 1 góźinu"\r
- two: "něźi {{count}} góźinoma"\r
- few: "něźi {{count}} góźinami"\r
- other: "něźi {{count}} góźinami"\r
- x_days:\r
- one: "1 dnjom"\r
- two: "{{count}} dnjoma"\r
- few: "{{count}} dnjami"\r
- other: "{{count}} dnjami"\r
- about_x_months:\r
- one: "něźi 1 mjasecom"\r
- two: "něźi {{count}} mjasecoma"\r
- few: "něźi {{count}} mjasecami"\r
- other: "něźi {{count}} mjasecami"\r
- x_months:\r
- one: "1 mjasecom"\r
- two: "{{count}} mjasecoma"\r
- few: "{{count}} mjasecami"\r
- other: "{{count}} mjasecami"\r
- about_x_years:\r
- one: "něźi 1 lětom"\r
- two: "něźi {{count}} lětoma"\r
- few: "něźi {{count}} lětami"\r
- other: "něźi {{count}} lětami"\r
- over_x_years:\r
- one: "wěcej ako 1 lětom"\r
- two: "wěcej ako {{count}} lětoma"\r
- few: "wěcej ako {{count}} lětami"\r
- other: "wěcej ako {{count}} lětami"\r
- prompts:\r
- year: "Lěto"\r
- month: "Mjasec"\r
- day: "Źeń"\r
- hour: "Góźina"\r
- minute: "Minuta"\r
- second: "Sekunda"\r
-\r
- # ActiveRecord validation messages\r
- activerecord:\r
- errors:\r
- messages:\r
- inclusion: "njejo płaśiwa gódnota"\r
- exclusion: "njestoj k dispoziciji"\r
- invalid: "njejo płaśiwy"\r
- confirmation: "njejo se wobkšuśiło"\r
- accepted: "musy se wobkšuśiś"\r
- empty: "njesmějo prozny byś"\r
- blank: "jo trěbny"\r
- too_long:\r
- one: "jo pśedłujki (maks. 1 znamješko)"\r
- two: "jo pśedłujki (maks. {{count}} znamješce)"\r
- few: "jo pśedłujki (maks. {{count}} znamješka)"\r
- other: "jo pśedłujki (maks. {{count}} znamješkow)"\r
- too_short:\r
- one: "jo překrotki (min. 1 znamješko)"\r
- two: "jo překrotki (min. {{count}} znamješće)"\r
- few: "jo překrotki (min. {{count}} znamješka)"\r
- other: "jo překrotki (min. {{count}} znamješkow)"\r
- wrong_length:\r
- one: "njama pšawu dłujkosć (1 znamješko wócakane)"\r
- two: "njama pšawu dłujkosć ({{count}} znamješce wócakanej)"\r
- few: "njama pšawu dłujkosć ({{count}} znamješka wócakane)"\r
- other: "njama pšawu dłujkosć ({{count}} znamješkow wócakanych)"\r
- taken: "jo južo w datowej bance"\r
- not_a_number: "njejo licba"\r
- greater_than: "musy wětšy ako {{count}} byś"\r
- greater_than_or_equal_to: "musy wětšy abo jadnak {{count}} być"\r
- equal_to: "musy jadnak {{count}} byś"\r
- less_than: "musy mjeńšy ako {{count}} byś"\r
- less_than_or_equal_to: "musy mjeńšy abo jadnak {{count}} byś"\r
- odd: "musy njerowna licba byś"\r
- even: "musy rowna licba byś"\r
-\r
- template:\r
- header:\r
- one: "Pśi składowanju objekta {{model}} jo k zmólce dojšło a njejo było móžno składowaś"\r
- two: "Pśi składowanju objekta {{model}} jo k {{count}} zmólkam dojšło a njejo było móžno składowaś"\r
- few: "Pśi składowanju objekta {{model}} jo k {{count}} zmólkam dojšło a njejo było móžno składowaś"\r
- other: "Pśi składowanju objekta {{model}} jo k {{count}} zmólkam dojšło a njejo było móžno składowaś"\r
- body: "Pšosym pśeglědaj slědujuce póla:"\r
-\r
- models:\r
+# Lower Sorbian translations for Ruby on Rails
+# by Michael Wolf (preklady@wolfmicha.de)
+
+dsb:
+ # ActiveSupport
+ support:
+ array:
+ words_connector: ", "
+ two_words_connector: " a "
+ last_word_connector: " a "
+ sentence_connector: "a"
+ skip_last_comma: true
+
+ # Date
+ date:
+ formats:
+ default: "%d. %m. %Y"
+ short: "%d %b"
+ long: "%d. %B %Y"
+ day_names: [njeźela, pónjeźele, wałtora, srjoda, stwórtk, pětk, sobota]
+ abbr_day_names: [Nj, Pó, Wu, Sr, St, Pě, So]
+ month_names: [~, Januar, Februar, Měrc, Apryl, Maj, Junij, Julij, Awgust, September, Oktober, Nowember, December]
+ abbr_month_names: [~, jan, feb, měr, apr, maj, jun, jul, awg, sep, okt, now, dec]
+ order: [:day, :month, :year]
+
+ # Time
+ time:
+ formats:
+ default: "%A, %d. %B %Y, %H:%M hodź"
+ short: "%d. %B, %H:%M hodź."
+ long: "%A, %d. %B %Y, %H:%M hodź."
+ am: "dopołdnja"
+ pm: "wótpołdnja"
+
+
+ # Numbers
+ number:
+ format:
+ precision: 3
+ separator: ","
+ delimiter: "."
+ currency:
+ format:
+ unit: "€"
+ precision: 2
+ format: "%n %u"
+ separator: ","
+ delimiter: " "
+ human:
+ format:
+ precision: 1
+ delimiter: ""
+ storage_units:
+ format: "%n %u"
+ units:
+ byte:
+ one: "bajt"
+ two: "bajta"
+ few: "bajty"
+ other: "bajtow"
+ kb: "KB"
+ mb: "MB"
+ gb: "GB"
+ tb: "TB"
+
+ percentage:
+ format:
+ delimiter: ""
+
+ precision:
+ format:
+ delimiter: ""
+
+
+ # Distance of time ... helper
+ # Used in distance_of_time_in_words(), distance_of_time_in_words_to_now(), time_ago_in_words()
+ datetime:
+ distance_in_words:
+ half_a_minute: "poł minuty"
+ less_than_x_seconds:
+ one: "mjenjej ako 1 sekundu"
+ two: "mjenjej ako {{count}} sekundoma"
+ few: "mjenjej ako {{count}} sekundami"
+ other: "mjenjej ako {{count}} sekundami"
+ x_seconds:
+ one: "1 sekundu"
+ two: "{{count}} sekundoma"
+ few: "{{count}} sekundami"
+ other: "{{count}} sekundami"
+ less_than_x_minutes:
+ one: "mjenjej ako 1 minutu"
+ two: "mjenjej ako {{count}} minutoma"
+ few: "mjenjej ako {{count}} minutami"
+ other: "mjenjej ako {{count}} minutami"
+ x_minutes:
+ one: "1 minutu"
+ two: "{{count}} minutoma"
+ few: "{{count}} minutami"
+ other: "{{count}} minutami"
+ about_x_hours:
+ one: "něźi 1 góźinu"
+ two: "něźi {{count}} góźinoma"
+ few: "něźi {{count}} góźinami"
+ other: "něźi {{count}} góźinami"
+ x_days:
+ one: "1 dnjom"
+ two: "{{count}} dnjoma"
+ few: "{{count}} dnjami"
+ other: "{{count}} dnjami"
+ about_x_months:
+ one: "něźi 1 mjasecom"
+ two: "něźi {{count}} mjasecoma"
+ few: "něźi {{count}} mjasecami"
+ other: "něźi {{count}} mjasecami"
+ x_months:
+ one: "1 mjasecom"
+ two: "{{count}} mjasecoma"
+ few: "{{count}} mjasecami"
+ other: "{{count}} mjasecami"
+ about_x_years:
+ one: "něźi 1 lětom"
+ two: "něźi {{count}} lětoma"
+ few: "něźi {{count}} lětami"
+ other: "něźi {{count}} lětami"
+ over_x_years:
+ one: "wěcej ako 1 lětom"
+ two: "wěcej ako {{count}} lětoma"
+ few: "wěcej ako {{count}} lětami"
+ other: "wěcej ako {{count}} lětami"
+ prompts:
+ year: "Lěto"
+ month: "Mjasec"
+ day: "Źeń"
+ hour: "Góźina"
+ minute: "Minuta"
+ second: "Sekunda"
+
+ # ActiveRecord validation messages
+ activerecord:
+ errors:
+ messages:
+ inclusion: "njejo płaśiwa gódnota"
+ exclusion: "njestoj k dispoziciji"
+ invalid: "njejo płaśiwy"
+ confirmation: "njejo se wobkšuśiło"
+ accepted: "musy se wobkšuśiś"
+ empty: "njesmějo prozny byś"
+ blank: "jo trěbny"
+ too_long:
+ one: "jo pśedłujki (maks. 1 znamješko)"
+ two: "jo pśedłujki (maks. {{count}} znamješce)"
+ few: "jo pśedłujki (maks. {{count}} znamješka)"
+ other: "jo pśedłujki (maks. {{count}} znamješkow)"
+ too_short:
+ one: "jo překrotki (min. 1 znamješko)"
+ two: "jo překrotki (min. {{count}} znamješće)"
+ few: "jo překrotki (min. {{count}} znamješka)"
+ other: "jo překrotki (min. {{count}} znamješkow)"
+ wrong_length:
+ one: "njama pšawu dłujkosć (1 znamješko wócakane)"
+ two: "njama pšawu dłujkosć ({{count}} znamješce wócakanej)"
+ few: "njama pšawu dłujkosć ({{count}} znamješka wócakane)"
+ other: "njama pšawu dłujkosć ({{count}} znamješkow wócakanych)"
+ taken: "jo južo w datowej bance"
+ not_a_number: "njejo licba"
+ greater_than: "musy wětšy ako {{count}} byś"
+ greater_than_or_equal_to: "musy wětšy abo jadnak {{count}} być"
+ equal_to: "musy jadnak {{count}} byś"
+ less_than: "musy mjeńšy ako {{count}} byś"
+ less_than_or_equal_to: "musy mjeńšy abo jadnak {{count}} byś"
+ odd: "musy njerowna licba byś"
+ even: "musy rowna licba byś"
+
+ template:
+ header:
+ one: "Pśi składowanju objekta {{model}} jo k zmólce dojšło a njejo było móžno składowaś"
+ two: "Pśi składowanju objekta {{model}} jo k {{count}} zmólkam dojšło a njejo było móžno składowaś"
+ few: "Pśi składowanju objekta {{model}} jo k {{count}} zmólkam dojšło a njejo było móžno składowaś"
+ other: "Pśi składowanju objekta {{model}} jo k {{count}} zmólkam dojšło a njejo było móžno składowaś"
+ body: "Pšosym pśeglědaj slědujuce póla:"
+
+ models:
# These are also the defaults for 'currency', 'percentage', 'precision', and 'human'
format:
# Sets the separator between the units, for more precision (e.g. 1.0 / 2.0 == 0.5)
- separator: ","
+ separator: ","
# Delimets thousands (e.g. 1,000,000 is a million) (always in groups of three)
- delimiter: "."
+ delimiter: "."
# Number of decimals, behind the separator (1 with a precision of 2 gives: 1.00)
precision: 3
currency:
format:
# Where is the currency sign? %u is the currency unit, %n the number (default: $5.00)
- format: "%n %u"
- unit: "€"
+ format: "%n %u"
+ unit: "€"
# These three are to override number.format and are optional
- separator: ","
- delimiter: "."
+ separator: ","
+ delimiter: "."
precision: 2
# Used in number_to_percentage()
percentage:
format:
# These three are to override number.format and are optional
- # separator:
- delimiter: ""
- # precision:
+ # separator:
+ delimiter: ""
+ # precision:
# Used in number_to_precision()
precision:
format:
# These three are to override number.format and are optional
# separator:
- delimiter: ""
+ delimiter: ""
# precision:
# Used in number_to_human_size()
human:
format:
# These three are to override number.format and are optional
- # separator:
- delimiter: ""
+ # separator:
+ delimiter: ""
precision: 1
# Rails <= v2.2.2
# storage_units: [Bytes, KB, MB, GB, TB]
# Used in distance_of_time_in_words(), distance_of_time_in_words_to_now(), time_ago_in_words()
datetime:
distance_in_words:
- half_a_minute: "medio minuto"
+ half_a_minute: "medio minuto"
less_than_x_seconds:
- one: "menos de 1 segundo"
+ one: "menos de 1 segundo"
other: "menos de {{count}} segundos"
x_seconds:
- one: "1 segundo"
- other: "{{count}} segundos"
+ one: "1 segundo"
+ other: "{{count}} segundos"
less_than_x_minutes:
- one: "menos de 1 minuto"
- other: "menos de {{count}} minutos"
+ one: "menos de 1 minuto"
+ other: "menos de {{count}} minutos"
x_minutes:
- one: "1 minuto"
- other: "{{count}} minutos"
+ one: "1 minuto"
+ other: "{{count}} minutos"
about_x_hours:
- one: "alrededor de 1 hora"
- other: "alrededor de {{count}} horas"
+ one: "alrededor de 1 hora"
+ other: "alrededor de {{count}} horas"
x_days:
- one: "1 día"
- other: "{{count}} días"
+ one: "1 día"
+ other: "{{count}} días"
about_x_months:
- one: "alrededor de 1 mes"
- other: "alrededor de {{count}} meses"
+ one: "alrededor de 1 mes"
+ other: "alrededor de {{count}} meses"
x_months:
- one: "1 mes"
- other: "{{count}} meses"
+ one: "1 mes"
+ other: "{{count}} meses"
about_x_years:
- one: "alrededor de 1 año"
- other: "alrededor de {{count}} años"
+ one: "alrededor de 1 año"
+ other: "alrededor de {{count}} años"
over_x_years:
- one: "más de 1 año"
- other: "más de {{count}} años"
+ one: "más de 1 año"
+ other: "más de {{count}} años"
almost_x_years:
one: "casi 1 año"
other: "casi {{count}} años"
errors:
template:
header:
- one: "no se pudo guardar este {{model}} porque se encontró 1 error"
- other: "no se pudo guardar este {{model}} porque se encontraron {{count}} errores"
+ one: "No se pudo guardar este/a {{model}} porque se encontró 1 error"
+ other: "No se pudo guardar este/a {{model}} porque se encontraron {{count}} errores"
# The variable :count is also available
- body: "Se encontraron problemas con los siguientes campos:"
+ body: "Se encontraron problemas con los siguientes campos:"
# The values :model, :attribute and :value are always available for interpolation
# The value :count is available when applicable. Can be used for pluralization.
messages:
- inclusion: "no está incluido en la lista"
- exclusion: "está reservado"
- invalid: "no es válido"
+ inclusion: "no está incluido en la lista"
+ exclusion: "está reservado"
+ invalid: "no es válido"
confirmation: "no coincide con la confirmación"
accepted: "debe ser aceptado"
empty: "no puede estar vacío"
record_invalid: "La validación falló: {{errors}}"
# Append your own errors here or at the model/attributes scope.
+ full_messages:
+ format: "{{attribute}} {{message}}"
+
models:
# Overrides default messages
# When no format has been given, it uses default.
# You can provide other formats here if you like!
default: "%e/%m/%Y"
- short: "%e de %b"
- long: "%e de %B de %Y"
+ short: "%e de %b"
+ long: "%e de %B de %Y"
day_names: [Domingo, Lunes, Martes, Miércoles, Jueves, Viernes, Sábado]
abbr_day_names: [Dom, Lun, Mar, Mie, Jue, Vie, Sab]
time:
formats:
default: "%A, %e de %B de %Y %H:%M:%S %z"
- short: "%e de %b %H:%M"
- long: "%e de %B de %Y %H:%M"
- am: "am"
- pm: "pm"
+ short: "%e de %b %H:%M"
+ long: "%e de %B de %Y %H:%M"
+ am: "am"
+ pm: "pm"
# Used in array.to_sentence.
support:
only_day: "%e"
day_names: [یکشنبه, دوشنبه, سهشنبه, چهارشنبه, پنجشنبه, جمعه, شنبه]
- abbr_day_names: [ی, د, س, چ, پ, ج]
+ abbr_day_names: [ی, د, س, چ, پ, ج, ش]
month_names: [~, ژانویه, فوریه, مارس, آوریل, مه, ژوئن, ژوئیه, اوت, سپتامبر, اکتبر, نوامبر, دسامبر]
abbr_month_names: [~, ژانویه, فوریه, مارس, آوریل, مه, ژوئن, ژوئیه, اوت, سپتامبر, اکتبر, نوامبر, دسامبر]
order: [ :day, :month, :year ]
odd: "باید فرد باشد"
even: "باید زوج باشد"
presence: "را فراموش کردهاید"
- format: "فرمت مشکل دارد"
\ No newline at end of file
+ format: "فرمت مشکل دارد"
words_connector: ", "
two_words_connector: " ja "
last_word_connector: " ja "
+ select:
+ prompt: "Valitse"
number:
format:
minute: "Minuutti"
second: "Sekunti"
- support:
- select:
- prompt: "Valitse"
-
# which one should it be
#activemodel:
activerecord:
-# Upper Sorbian translations for Ruby on Rails\r
-# by Michael Wolf (preklady@wolfmicha.de)\r
-\r
-hsb:\r
-\r
- # ActiveSupport\r
- support:\r
- array:\r
- words_connector: ", "\r
- two_words_connector: " a "\r
- last_word_connector: " a "\r
- sentence_connector: "a"\r
- skip_last_comma: true\r
-\r
-\r
-\r
- # Date\r
- date:\r
- formats:\r
- default: "%d. %m. %Y"\r
- short: "%d %b"\r
- long: "%d. %B %Y"\r
-\r
- day_names: [njedźela, póndźela, wutora, srjeda, štwórtk, pjatk, sobota]\r
- abbr_day_names: [Nj, Pó, Wu, Sr, Št, Pj, So]\r
- month_names: [~, Januar, Februar, Měrc, Apryl, Meja, Junij, Julij, Awgust, September, Oktober, Nowember, December]\r
- abbr_month_names: [~, jan, feb, měr, apr, mej, jun, jul, awg, sep, okt, now, dec]\r
- order: [:day, :month, :year]\r
-\r
- # Time\r
- time:\r
- formats:\r
- default: "%A, %d. %B %Y, %H:%M hodź"\r
- short: "%d. %B, %H:%M hodź."\r
- long: "%A, %d. %B %Y, %H:%M hodź."\r
-\r
- am: "dopołdnja"\r
- pm: "popołdnju"\r
-\r
-\r
- # Numbers\r
- number:\r
- format:\r
- precision: 3\r
- separator: ","\r
- delimiter: "."\r
-\r
- currency:\r
- format:\r
- unit: "€"\r
- precision: 2\r
- format: "%n %u"\r
- separator: ","\r
- delimiter: " "\r
-\r
- human:\r
- format:\r
- precision: 1\r
- delimiter: ""\r
-\r
- storage_units:\r
- format: "%n %u"\r
- units:\r
- byte:\r
- one: "bajt"\r
- two: "bajtaj"\r
- few: "bajty"\r
- other: "bajtow"\r
- kb: "KB"\r
- mb: "MB"\r
- gb: "GB"\r
- tb: "TB"\r
-\r
- percentage:\r
- format:\r
- delimiter: ""\r
-\r
- precision:\r
- format:\r
- delimiter: ""\r
-\r
-\r
- # Distance of time ... helper\r
- # Used in distance_of_time_in_words(), distance_of_time_in_words_to_now(), time_ago_in_words()\r
- datetime:\r
- distance_in_words:\r
- half_a_minute: "poł mjeńšiny"\r
- less_than_x_seconds:\r
- one: "mjenje hač 1 sekundu"\r
- two: "mjenje hač {{count}} sekundomaj"\r
- few: "mjenje hač {{count}} sekundami"\r
- other: "mjenje hač {{count}} sekundami"\r
- x_seconds:\r
- one: "1 sekundu"\r
- two: "{{count}} sekundomaj"\r
- few: "{{count}} sekundami"\r
- other: "{{count}} sekundami"\r
- less_than_x_minutes:\r
- one: "mjenje hač 1 mjeńšinu"\r
- two: "mjenje hač {{count}} mjeńšinomaj"\r
- few: "mjenje hač {{count}} mjeńšinami"\r
- other: "mjenje hač {{count}} mjeńšinami"\r
- x_minutes:\r
- one: "1 mjeńšinu"\r
- two: "{{count}} mjeńšinomaj"\r
- few: "{{count}} mjeńšinami"\r
- other: "{{count}} mjeńšinami"\r
- about_x_hours:\r
- one: "něhdźe 1 hodźinu"\r
- two: "něhdźe {{count}} hodźinomaj"\r
- few: "něhdźe {{count}} hodźinami"\r
- other: "něhdźe {{count}} hodźinami"\r
- x_days:\r
- one: "1 dnjom"\r
- two: "{{count}} dnjomaj"\r
- few: "{{count}} dnjemi"\r
- other: "{{count}} dnjemi"\r
- about_x_months:\r
- one: "něhdźe 1 měsacom"\r
- two: "něhdźe {{count}} měsacomaj"\r
- few: "něhdźe {{count}} měsacami"\r
- other: "něhdźe {{count}} měsacami"\r
- x_months:\r
- one: "1 měsacom"\r
- two: "{{count}} měsacomaj"\r
- few: "{{count}} měsacami"\r
- other: "{{count}} měsacami"\r
- about_x_years:\r
- one: "něhdźe 1 lětom"\r
- two: "něhdźe {{count}} lětomaj"\r
- few: "něhdźe {{count}} lětami"\r
- other: "něhdźe {{count}} lětami"\r
- over_x_years:\r
- one: "přez 1 lětom"\r
- two: "přez {{count}} lětomaj"\r
- few: "přez {{count}} lětami"\r
- other: "přez {{count}} lětami"\r
- prompts:\r
- year: "Lěto"\r
- month: "Měsac"\r
- day: "Dźeń"\r
- hour: "Hodźina"\r
- minute: "Mjeńšina"\r
- second: "Sekunda"\r
-\r
- # ActiveRecord validation messages\r
- activerecord:\r
- errors:\r
- messages:\r
- inclusion: "njeje płaćiwa hódnota"\r
- exclusion: "njesteji k dispoziciji"\r
- invalid: "njeje płaćiwy"\r
- confirmation: "njebu wobkrućene"\r
- accepted: "dyrbi so wobkrućić"\r
- empty: "njesmě prózdny być"\r
- blank: "je trěbny"\r
- too_long: \r
- one: "je předołhi (maks. 1 znamješko)"\r
- two: "je předołhi (maks. {{count}} znamješce)"\r
- few: "je předołhi (maks. {{count}} znamješka)"\r
- other: "je předołhi (maks. {{count}} znamješkow)"\r
- too_short: \r
- one: "je překrótki (min. 1 znamješko)"\r
- two: "je překrótki (min. {{count}} znamješće)"\r
- few: "je překrótki (min. {{count}} znamješka)"\r
- other: "je překrótki (min. {{count}} znamješkow)"\r
- wrong_length:\r
- one: "nima prawu dołhosć (1 znamješko wočakowane)"\r
- two: "nima prawu dołhosć ({{count}} znamješce wočakowanej)"\r
- few: "nima prawu dołhosć ({{count}} znamješka wočakowane)"\r
- other: "nima prawu dołhosć ({{count}} znamješkow wočakowanych)"\r
- taken: "je hižo w datowej bance"\r
- not_a_number: "njeje ličba"\r
- greater_than: "dyrbi wjetši hač {{count}} być"\r
- greater_than_or_equal_to: "dyrbi wjetši abo runja {{count}} być"\r
- equal_to: "dyrbi runja {{count}} być"\r
- less_than: "dyrbi mjenje hač {{count}} być"\r
- less_than_or_equal_to: "dyrbi mjenje abo runja {{count}} być"\r
- odd: "dyrbi njeruna ličby być"\r
- even: "dyrbi runa ličba być"\r
-\r
- template:\r
- header:\r
- one: "Při składowanju objekta {{model}} je k zmylkej dóšło a njebě móžno składować"\r
- two: "Při składowanju objekta {{model}} je k {{count}} zmylkam dóšło a njebě móžno składować"\r
- few: "Při składowanju objekta {{model}} je k {{count}} zmylkam dóšło a njebě móžno składować"\r
- other: "Při składowanju objekta {{model}} je k {{count}} zmylkam dóšło a njebě móžno składować"\r
- body: "Prošu přepruwuj slědowace pola:"\r
-\r
- models:\r
+# Upper Sorbian translations for Ruby on Rails
+# by Michael Wolf (preklady@wolfmicha.de)
+
+hsb:
+
+ # ActiveSupport
+ support:
+ array:
+ words_connector: ", "
+ two_words_connector: " a "
+ last_word_connector: " a "
+ sentence_connector: "a"
+ skip_last_comma: true
+
+
+
+ # Date
+ date:
+ formats:
+ default: "%d. %m. %Y"
+ short: "%d %b"
+ long: "%d. %B %Y"
+
+ day_names: [njedźela, póndźela, wutora, srjeda, štwórtk, pjatk, sobota]
+ abbr_day_names: [Nj, Pó, Wu, Sr, Št, Pj, So]
+ month_names: [~, Januar, Februar, Měrc, Apryl, Meja, Junij, Julij, Awgust, September, Oktober, Nowember, December]
+ abbr_month_names: [~, jan, feb, měr, apr, mej, jun, jul, awg, sep, okt, now, dec]
+ order: [:day, :month, :year]
+
+ # Time
+ time:
+ formats:
+ default: "%A, %d. %B %Y, %H:%M hodź"
+ short: "%d. %B, %H:%M hodź."
+ long: "%A, %d. %B %Y, %H:%M hodź."
+
+ am: "dopołdnja"
+ pm: "popołdnju"
+
+
+ # Numbers
+ number:
+ format:
+ precision: 3
+ separator: ","
+ delimiter: "."
+
+ currency:
+ format:
+ unit: "€"
+ precision: 2
+ format: "%n %u"
+ separator: ","
+ delimiter: " "
+
+ human:
+ format:
+ precision: 1
+ delimiter: ""
+
+ storage_units:
+ format: "%n %u"
+ units:
+ byte:
+ one: "bajt"
+ two: "bajtaj"
+ few: "bajty"
+ other: "bajtow"
+ kb: "KB"
+ mb: "MB"
+ gb: "GB"
+ tb: "TB"
+
+ percentage:
+ format:
+ delimiter: ""
+
+ precision:
+ format:
+ delimiter: ""
+
+
+ # Distance of time ... helper
+ # Used in distance_of_time_in_words(), distance_of_time_in_words_to_now(), time_ago_in_words()
+ datetime:
+ distance_in_words:
+ half_a_minute: "poł mjeńšiny"
+ less_than_x_seconds:
+ one: "mjenje hač 1 sekundu"
+ two: "mjenje hač {{count}} sekundomaj"
+ few: "mjenje hač {{count}} sekundami"
+ other: "mjenje hač {{count}} sekundami"
+ x_seconds:
+ one: "1 sekundu"
+ two: "{{count}} sekundomaj"
+ few: "{{count}} sekundami"
+ other: "{{count}} sekundami"
+ less_than_x_minutes:
+ one: "mjenje hač 1 mjeńšinu"
+ two: "mjenje hač {{count}} mjeńšinomaj"
+ few: "mjenje hač {{count}} mjeńšinami"
+ other: "mjenje hač {{count}} mjeńšinami"
+ x_minutes:
+ one: "1 mjeńšinu"
+ two: "{{count}} mjeńšinomaj"
+ few: "{{count}} mjeńšinami"
+ other: "{{count}} mjeńšinami"
+ about_x_hours:
+ one: "něhdźe 1 hodźinu"
+ two: "něhdźe {{count}} hodźinomaj"
+ few: "něhdźe {{count}} hodźinami"
+ other: "něhdźe {{count}} hodźinami"
+ x_days:
+ one: "1 dnjom"
+ two: "{{count}} dnjomaj"
+ few: "{{count}} dnjemi"
+ other: "{{count}} dnjemi"
+ about_x_months:
+ one: "něhdźe 1 měsacom"
+ two: "něhdźe {{count}} měsacomaj"
+ few: "něhdźe {{count}} měsacami"
+ other: "něhdźe {{count}} měsacami"
+ x_months:
+ one: "1 měsacom"
+ two: "{{count}} měsacomaj"
+ few: "{{count}} měsacami"
+ other: "{{count}} měsacami"
+ about_x_years:
+ one: "něhdźe 1 lětom"
+ two: "něhdźe {{count}} lětomaj"
+ few: "něhdźe {{count}} lětami"
+ other: "něhdźe {{count}} lětami"
+ over_x_years:
+ one: "přez 1 lětom"
+ two: "přez {{count}} lětomaj"
+ few: "přez {{count}} lětami"
+ other: "přez {{count}} lětami"
+ prompts:
+ year: "Lěto"
+ month: "Měsac"
+ day: "Dźeń"
+ hour: "Hodźina"
+ minute: "Mjeńšina"
+ second: "Sekunda"
+
+ # ActiveRecord validation messages
+ activerecord:
+ errors:
+ messages:
+ inclusion: "njeje płaćiwa hódnota"
+ exclusion: "njesteji k dispoziciji"
+ invalid: "njeje płaćiwy"
+ confirmation: "njebu wobkrućene"
+ accepted: "dyrbi so wobkrućić"
+ empty: "njesmě prózdny być"
+ blank: "je trěbny"
+ too_long:
+ one: "je předołhi (maks. 1 znamješko)"
+ two: "je předołhi (maks. {{count}} znamješce)"
+ few: "je předołhi (maks. {{count}} znamješka)"
+ other: "je předołhi (maks. {{count}} znamješkow)"
+ too_short:
+ one: "je překrótki (min. 1 znamješko)"
+ two: "je překrótki (min. {{count}} znamješće)"
+ few: "je překrótki (min. {{count}} znamješka)"
+ other: "je překrótki (min. {{count}} znamješkow)"
+ wrong_length:
+ one: "nima prawu dołhosć (1 znamješko wočakowane)"
+ two: "nima prawu dołhosć ({{count}} znamješce wočakowanej)"
+ few: "nima prawu dołhosć ({{count}} znamješka wočakowane)"
+ other: "nima prawu dołhosć ({{count}} znamješkow wočakowanych)"
+ taken: "je hižo w datowej bance"
+ not_a_number: "njeje ličba"
+ greater_than: "dyrbi wjetši hač {{count}} być"
+ greater_than_or_equal_to: "dyrbi wjetši abo runja {{count}} być"
+ equal_to: "dyrbi runja {{count}} być"
+ less_than: "dyrbi mjenje hač {{count}} być"
+ less_than_or_equal_to: "dyrbi mjenje abo runja {{count}} być"
+ odd: "dyrbi njeruna ličby być"
+ even: "dyrbi runa ličba być"
+
+ template:
+ header:
+ one: "Při składowanju objekta {{model}} je k zmylkej dóšło a njebě móžno składować"
+ two: "Při składowanju objekta {{model}} je k {{count}} zmylkam dóšło a njebě móžno składować"
+ few: "Při składowanju objekta {{model}} je k {{count}} zmylkam dóšło a njebě móžno składować"
+ other: "Při składowanju objekta {{model}} je k {{count}} zmylkam dóšło a njebě móžno składować"
+ body: "Prošu přepruwuj slědowace pola:"
+
+ models:
-# Sample localization file for English. Add more files in this directory for other locales.\r
-# See http://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.\r
-\r
-# Slovak translations for Ruby on Rails (inspired by the Czech localization - thanx to Karel Minařík)\r
-# by Jozef Fulop (jofi-rails@silake.com)\r
- \r
-sk:\r
- # ActiveSupport\r
- support:\r
- array:\r
- words_connector: ', '\r
- two_words_connector: ' a '\r
- last_word_connector: ' a '\r
- \r
- # Date\r
- date:\r
- formats:\r
- default: "%d. %m. %Y"\r
- short: "%d %b"\r
- long: "%d. %B %Y"\r
- day_names: [Nedeľa, Pondelok, Utorok, Streda, Štvrtok, Piatok, Sobota]\r
- abbr_day_names: [Ne, Po, Ut, St, Št, Pi, So]\r
- month_names: [~, Január, Február, Marec, Apríl, Máj, Jún, Júl, August, September, Október, November, December]\r
- abbr_month_names: [~, Jan, Feb, Mar, Apr, Máj, Jún, Júl, Aug, Sep, Okt, Nov, Dec]\r
- order: [:day, :month, :year]\r
-\r
- # Time\r
- time:\r
- formats:\r
- default: "%a %d. %B %Y %H:%M %z"\r
- short: "%d. %m. %H:%M"\r
- long: "%A %d. %B %Y %H:%M"\r
- am: 'dopoludnia'\r
- pm: 'popoludní'\r
-\r
- # Numbers\r
- number:\r
- format:\r
- precision: 3\r
- separator: '.'\r
- delimiter: ','\r
- currency:\r
- format:\r
- unit: '€'\r
- precision: 2\r
- format: '%n %u'\r
- separator: ","\r
- delimiter: " "\r
- human:\r
- format:\r
- precision: 1\r
- delimiter: ''\r
- storage_units:\r
- format: "%n %u"\r
- units:\r
- byte:\r
- other: "B"\r
- one: "B"\r
- kb: "KB"\r
- mb: "MB"\r
- gb: "GB"\r
- tb: "TB"\r
- percentage:\r
- format:\r
- delimiter: ''\r
- precision:\r
- format:\r
- delimiter: ''\r
- \r
- # Distance of time ... helper\r
- datetime:\r
- prompts:\r
- second: "Sekunda"\r
- minute: "Minúta"\r
- hour: "Hodina"\r
- day: "Deň"\r
- month: "Mesiac"\r
- year: "Rok"\r
- distance_in_words: \r
- half_a_minute: 'pol minutou'\r
- less_than_x_seconds:\r
- one: 'asi pred sekundou'\r
- other: 'asi pred {{count}} sekundami'\r
- x_seconds:\r
- one: 'sekundou'\r
- other: '{{count}} sekundami'\r
- less_than_x_minutes:\r
- one: 'pred necelou minútou'\r
- other: 'pred ani nie {{count}} minútami'\r
- x_minutes:\r
- one: 'minútou'\r
- other: '{{count}} minútami'\r
- about_x_hours:\r
- one: 'asi hodinou'\r
- other: 'asi {{count}} hodinami'\r
- x_days:\r
- one: '24 hodinami'\r
- other: '{{count}} dňami'\r
- about_x_months:\r
- one: 'asi mesiacom'\r
- other: 'asi {{count}} mesiacmi'\r
- x_months:\r
- one: 'mesiacom'\r
- other: '{{count}} mesiacmi'\r
- about_x_years:\r
- one: 'asi rokom'\r
- other: 'asi {{count}} rokmi'\r
- over_x_years:\r
- one: 'pred viac ako rokom'\r
- other: 'viac ako {{count}} rokmi'\r
-\r
- # ActiveRecord validation messages\r
- activerecord: \r
- errors:\r
- messages:\r
- inclusion: "nie je v zozname povolených hodnôt"\r
- exclusion: "je vyhradené pre iný účel"\r
- invalid: "nie je platná hodnota"\r
- confirmation: "nebolo potvrdené"\r
- accepted: "musí byť potvrdené"\r
- empty: "nesmie byť prázdný/é"\r
- blank: "je povinná položka"\r
- too_long: "je príliš dlhá/ý (max. {{count}} znakov)"\r
- too_short: "je príliš krátký/á (min. {{count}} znakov)"\r
- wrong_length: "nemá správnu dĺžku (očakáva sa {{count}} znakov)"\r
- taken: "sa už nachádza v databáze"\r
- not_a_number: "nie je číslo"\r
- greater_than: "musí byť väčšíe ako {{count}}"\r
- greater_than_or_equal_to: "musí byť väčšie alebo rovnaké ako {{count}}"\r
- equal_to: "sa musí rovnať {{count}}"\r
- less_than: "musí byť menšie ako {{count}}"\r
- less_than_or_equal_to: "musí byť menšie ako {{count}}"\r
- odd: "musí byť nepárne číslo"\r
- even: "musí byť párne číslo"\r
- template:\r
- header:\r
- one: "Pri ukladaní objektu {{model}} došlo k chybám a nebolo možné objekt uložiť"\r
- other: "Pri ukladaní objektu {{model}} došlo ku {{count}} chybe/ám a nebolo možné objekt uložiť"\r
- body: "Nasledujúce polia obsahujú chybne vyplnené údaje:"\r
+# Sample localization file for English. Add more files in this directory for other locales.
+# See http://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
+
+# Slovak translations for Ruby on Rails (inspired by the Czech localization - thanx to Karel Minařík)
+# by Jozef Fulop (jofi-rails@silake.com)
+
+sk:
+ # ActiveSupport
+ support:
+ array:
+ words_connector: ', '
+ two_words_connector: ' a '
+ last_word_connector: ' a '
+
+ # Date
+ date:
+ formats:
+ default: "%d. %m. %Y"
+ short: "%d %b"
+ long: "%d. %B %Y"
+ day_names: [Nedeľa, Pondelok, Utorok, Streda, Štvrtok, Piatok, Sobota]
+ abbr_day_names: [Ne, Po, Ut, St, Št, Pi, So]
+ month_names: [~, Január, Február, Marec, Apríl, Máj, Jún, Júl, August, September, Október, November, December]
+ abbr_month_names: [~, Jan, Feb, Mar, Apr, Máj, Jún, Júl, Aug, Sep, Okt, Nov, Dec]
+ order: [:day, :month, :year]
+
+ # Time
+ time:
+ formats:
+ default: "%a %d. %B %Y %H:%M %z"
+ short: "%d. %m. %H:%M"
+ long: "%A %d. %B %Y %H:%M"
+ am: 'dopoludnia'
+ pm: 'popoludní'
+
+ # Numbers
+ number:
+ format:
+ precision: 3
+ separator: '.'
+ delimiter: ','
+ currency:
+ format:
+ unit: '€'
+ precision: 2
+ format: '%n %u'
+ separator: ","
+ delimiter: " "
+ human:
+ format:
+ precision: 1
+ delimiter: ''
+ storage_units:
+ format: "%n %u"
+ units:
+ byte:
+ other: "B"
+ one: "B"
+ kb: "KB"
+ mb: "MB"
+ gb: "GB"
+ tb: "TB"
+ percentage:
+ format:
+ delimiter: ''
+ precision:
+ format:
+ delimiter: ''
+
+ # Distance of time ... helper
+ datetime:
+ prompts:
+ second: "Sekunda"
+ minute: "Minúta"
+ hour: "Hodina"
+ day: "Deň"
+ month: "Mesiac"
+ year: "Rok"
+ distance_in_words:
+ half_a_minute: 'pol minutou'
+ less_than_x_seconds:
+ one: 'asi pred sekundou'
+ other: 'asi pred {{count}} sekundami'
+ x_seconds:
+ one: 'sekundou'
+ other: '{{count}} sekundami'
+ less_than_x_minutes:
+ one: 'pred necelou minútou'
+ other: 'pred ani nie {{count}} minútami'
+ x_minutes:
+ one: 'minútou'
+ other: '{{count}} minútami'
+ about_x_hours:
+ one: 'asi hodinou'
+ other: 'asi {{count}} hodinami'
+ x_days:
+ one: '24 hodinami'
+ other: '{{count}} dňami'
+ about_x_months:
+ one: 'asi mesiacom'
+ other: 'asi {{count}} mesiacmi'
+ x_months:
+ one: 'mesiacom'
+ other: '{{count}} mesiacmi'
+ about_x_years:
+ one: 'asi rokom'
+ other: 'asi {{count}} rokmi'
+ over_x_years:
+ one: 'pred viac ako rokom'
+ other: 'viac ako {{count}} rokmi'
+
+ # ActiveRecord validation messages
+ activerecord:
+ errors:
+ messages:
+ inclusion: "nie je v zozname povolených hodnôt"
+ exclusion: "je vyhradené pre iný účel"
+ invalid: "nie je platná hodnota"
+ confirmation: "nebolo potvrdené"
+ accepted: "musí byť potvrdené"
+ empty: "nesmie byť prázdný/é"
+ blank: "je povinná položka"
+ too_long: "je príliš dlhá/ý (max. {{count}} znakov)"
+ too_short: "je príliš krátký/á (min. {{count}} znakov)"
+ wrong_length: "nemá správnu dĺžku (očakáva sa {{count}} znakov)"
+ taken: "sa už nachádza v databáze"
+ not_a_number: "nie je číslo"
+ greater_than: "musí byť väčšíe ako {{count}}"
+ greater_than_or_equal_to: "musí byť väčšie alebo rovnaké ako {{count}}"
+ equal_to: "sa musí rovnať {{count}}"
+ less_than: "musí byť menšie ako {{count}}"
+ less_than_or_equal_to: "musí byť menšie ako {{count}}"
+ odd: "musí byť nepárne číslo"
+ even: "musí byť párne číslo"
+ template:
+ header:
+ one: "Pri ukladaní objektu {{model}} došlo k chybám a nebolo možné objekt uložiť"
+ other: "Pri ukladaní objektu {{model}} došlo ku {{count}} chybe/ám a nebolo možné objekt uložiť"
+ body: "Nasledujúce polia obsahujú chybne vyplnené údaje:"
-Copyright (c) 2006 Alex Dunae\r
-\r
-Permission is hereby granted, free of charge, to any person obtaining\r
-a copy of this software and associated documentation files (the\r
-"Software"), to deal in the Software without restriction, including\r
-without limitation the rights to use, copy, modify, merge, publish,\r
-distribute, sublicense, and/or sell copies of the Software, and to\r
-permit persons to whom the Software is furnished to do so, subject to\r
-the following conditions:\r
-\r
-The above copyright notice and this permission notice shall be\r
-included in all copies or substantial portions of the Software.\r
-\r
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\r
-LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\r
-OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\r
-WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
+Copyright (c) 2006 Alex Dunae
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-require 'validates_email_format_of'\r
+require 'validates_email_format_of'