将prototype框架替换为jquery框架,修改了文件列表、评论分页、在线下载申请表单的ajax功能
This commit is contained in:
parent
aec40454af
commit
29c16cc6a0
|
@ -9,11 +9,12 @@
|
||||||
$this->breadcrumb('查看元数据');
|
$this->breadcrumb('查看元数据');
|
||||||
$this->breadcrumb()->setSeparator(' > ');
|
$this->breadcrumb()->setSeparator(' > ');
|
||||||
$this->headScript()->appendFile('http://maps.google.cn/maps?file=api&v=2&key='.$this->config->google->maps->api);
|
$this->headScript()->appendFile('http://maps.google.cn/maps?file=api&v=2&key='.$this->config->google->maps->api);
|
||||||
$this->headScript()->appendFile('/js/prototype.js');
|
$this->headScript()->appendFile('/js/jquery-1.6.4.min.js');
|
||||||
$this->headScript()->appendFile('/js/OpenLayers.js');
|
$this->headScript()->appendFile('/static/js/jquery.thickbox.js');
|
||||||
$this->headScript()->appendFile('/js/window.js');
|
|
||||||
$this->headScript()->appendFile('/js/pubfunc.js');
|
$this->headScript()->appendFile('/js/pubfunc.js');
|
||||||
$this->headLink()->appendStylesheet('/js/theme/default/style.css');
|
$this->headLink()->appendStylesheet('/js/theme/default/style.css');
|
||||||
|
$this->headLink()->appendStylesheet('/static/css/thickbox.css');
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<?php $md=$this->metadata;if ($md):?>
|
<?php $md=$this->metadata;if ($md):?>
|
||||||
<h1><?php echo $this->escape($md->title);
|
<h1><?php echo $this->escape($md->title);
|
||||||
|
@ -92,13 +93,13 @@ else
|
||||||
}?>">数据说明文档</a></li>
|
}?>">数据说明文档</a></li>
|
||||||
<li>附件:<?php echo $this->attachment;?></li>
|
<li>附件:<?php echo $this->attachment;?></li>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<li id="datatype">数据共享方式:<?php if ($md->datatype) print "离线"; else print "在线(可直接下载)";?> <a href="#" id="show-list" rel="<?php echo $md->uuid;?>">文件列表</a></li>
|
<li id="datatype">数据共享方式:<?php if ($md->datatype) print "离线"; else print "在线(可直接下载)";?> <a href="javascript:void(0);" id="show-list" onclick="getFileList()" title="">文件列表</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
<div id="linkurl">
|
<div id="linkurl">
|
||||||
<?php if ($md->status>0 and $md->status<5) : ?>
|
<?php if ($md->status>0 and $md->status<5) : ?>
|
||||||
<a href="/review/review/uuid/<?php echo $md->uuid; ?>"><img src="/images/review.png" title="此数据正在评审中,我们邀请您对此数据进行评审,以便其能尽快发布!" /></a>
|
<a href="/review/review/uuid/<?php echo $md->uuid; ?>"><img src="/images/review.png" title="此数据正在评审中,我们邀请您对此数据进行评审,以便其能尽快发布!" /></a>
|
||||||
<?php else : if (!$md->datatype) : ?>
|
<?php else : if (!$md->datatype) : ?>
|
||||||
<a href="javascript:$('todownload').show();todownload(1);"><img src="/images/download.png" title="直接下载" /></a>
|
<a href="javascript:$('#todownload').show();todownload(1);"><img src="/images/download.png" title="直接下载" /></a>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<a href="/data/order/uuid/<?php echo $md->uuid; ?>"><img src="/images/order.png" title="免费!离线申请此数据(在线数据和离线数据都可申请)"/></a>
|
<a href="/data/order/uuid/<?php echo $md->uuid; ?>"><img src="/images/order.png" title="免费!离线申请此数据(在线数据和离线数据都可申请)"/></a>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
@ -148,7 +149,7 @@ endforeach;
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div id="left">
|
<div id="left">
|
||||||
<div id="ImageViewer"><img src="/service/thumb/id/<?php echo $md->id;?>" onclick="fnCreate('<?php echo $this->thumburl; ?>')" /> </div>
|
<div id="ImageViewer"><a class="thickbox" title="" href="<?php echo $this->thumburl; ?>"><img src="/service/thumb/id/<?php echo $md->id;?>"/></a></div>
|
||||||
<div id="abstract">
|
<div id="abstract">
|
||||||
<p>
|
<p>
|
||||||
<?php echo str_replace(array("\r\n", "\n", "\r"),'</p><p>',$md->description);?>
|
<?php echo str_replace(array("\r\n", "\n", "\r"),'</p><p>',$md->description);?>
|
||||||
|
@ -261,11 +262,11 @@ echo '</li>';
|
||||||
<?php echo $this->commentForm; ?>
|
<?php echo $this->commentForm; ?>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="window-outter" style="display:none;">
|
<div id="window-outter" style="display:none;">
|
||||||
<div id="window-inner">
|
<div id="window-inner">
|
||||||
<div id="window-closer-container">[<a href="#" id="window-closer">关闭</a>]</div>
|
<div id="window-closer-container">[<a href="#" id="window-closer" onclick="$('#window-outter').hide()">关闭</a>]</div>
|
||||||
<div id="window-content-container">
|
<div id="window-content-container">
|
||||||
<div id="window-loading">加载中...</div>
|
<div id="window-loading">加载中...</div>
|
||||||
<ol id="file-list">
|
<ol id="file-list">
|
||||||
|
@ -273,8 +274,9 @@ echo '</li>';
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="todownload" style="display:none;">
|
<div id="todownload" style="display:none;">
|
||||||
<div class="closeox"><a href="javascript:void(0);" onclick="$('todownload').hide()">[关闭]</a></div>
|
<div class="closeox"><a href="javascript:void(0);" onclick="$('#todownload').hide()">[关闭]</a></div>
|
||||||
<div id="returninfo" style="">
|
<div id="returninfo" style="">
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
@ -283,40 +285,93 @@ echo '</li>';
|
||||||
//ajax download
|
//ajax download
|
||||||
function todownload(ft)
|
function todownload(ft)
|
||||||
{
|
{
|
||||||
var request_url = "/data/todownload/uuid/<?php echo $md->uuid;?>/ft/"+ft;
|
var url = "/data/todownload/uuid/<?php echo $md->uuid;?>/ft/"+ft;
|
||||||
if($('todownloadform')) {var request_pars = $('todownloadform').serialize();}else{var request_pars = '';}
|
if($('#todownloadform')) var date = $('#todownloadform').serialize();
|
||||||
|
$.ajax({
|
||||||
var myAjax = new Ajax.Updater('returninfo', request_url,{
|
type:"GET",
|
||||||
method : 'get',
|
url:url,
|
||||||
parameters : request_pars,
|
data:date,
|
||||||
onFailure : reportError,
|
success:function(html){
|
||||||
onLoading : loading,
|
$('#returninfo').html(html);
|
||||||
onComplete : done,
|
},
|
||||||
evalScripts: true
|
beforeSend:function(){
|
||||||
|
$('#returninfo').html('<img src="/images/11887177066.gif" />');
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
//ajax comment
|
//ajax comment
|
||||||
function loading(){$('loading').style.display = 'block';}
|
|
||||||
function done(){$('loading').style.display = 'none';}
|
|
||||||
function reportError(request){alert('Sorry. There was an error.');}
|
|
||||||
function ajaxpage(page){
|
function ajaxpage(page){
|
||||||
var request_pars = 'page='+page; //请求参数
|
var url = "/data/comment/uuid/<?= $md->uuid; ?>";
|
||||||
var myAjax = new Ajax.Updater('allcomments', '/data/comment/uuid/<?= $md->uuid; ?>',{
|
data='page='+page;
|
||||||
method : 'get', // http 请求方法,get or post
|
$.ajax({
|
||||||
parameters : request_pars, // 请求参数
|
type:"GET",
|
||||||
onFailure : reportError, // 失败的时候调用 reportError 函数处理
|
url:url,
|
||||||
onLoading : loading, // 加载时
|
data:data,
|
||||||
onComplete : done // 读取完毕
|
success:function(html){$('#allcomments').html(html);},
|
||||||
});
|
beforeSend:function(){$('#allcomments').html('<img src="/images/loading.gif" />评论加载中');}
|
||||||
|
});
|
||||||
|
};ajaxpage(0);
|
||||||
|
function getFileList(){
|
||||||
|
var tw = ($(window).width() - $('#window-outter').width())/2;
|
||||||
|
$('#window-inner').css('min-height','450px');
|
||||||
|
$('#window-outter').css({'right':tw});
|
||||||
|
$('#window-outter').show();
|
||||||
|
$.getJSON("/filelist/uuid/<?php echo $md->uuid;?>", function(data) {
|
||||||
|
var items = [];
|
||||||
|
if(data.length>0)
|
||||||
|
{
|
||||||
|
$.each(data, function(key, val) {
|
||||||
|
if(val['filename'].match(/\/$/))
|
||||||
|
{
|
||||||
|
items.push('<li id="li_' + val['id'] + '"><span id="span_'+val['id']+'">+</span> <a href="javascript:;" id="taget_'+val['id']+'" onclick="getSubFileList(\'' +val['uuid']+ '\',\''+val['id']+'\',\''+val['depth']+'\')">' + val['filename'] + '</a></li>');
|
||||||
|
}else{
|
||||||
|
items.push('<li id="li_' + val['id'] + '">' + val['filename'] + '</li>');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}else{
|
||||||
|
items.push('<li>暂无数据</li>');
|
||||||
|
}
|
||||||
|
$('#file-list').html(items.join(''));
|
||||||
|
})
|
||||||
|
.complete(function() {$('#window-loading').hide();});
|
||||||
}
|
}
|
||||||
ajaxpage(0);
|
function getSubFileList(uuid,id,depth){
|
||||||
//google map
|
if($("#div_"+id).length>0)
|
||||||
var map = new GMap2(document.getElementById("watermap"));
|
{
|
||||||
var plotbounds=new GLatLngBounds(new GLatLng(<?= $md->south; ?>,<?= $md->west; ?>),new GLatLng(<?= $md->north; ?>,<?= $md->east; ?>));
|
$('#span_'+id).html('+');
|
||||||
var zoomlevel=map.getBoundsZoomLevel(plotbounds);
|
$("#div_"+id).remove();
|
||||||
zoomlevel--;
|
return false;
|
||||||
|
}
|
||||||
|
$('<div/>', {
|
||||||
|
'style':'max-height:400px; overflow:scroll; overflow-x:hidden;',
|
||||||
|
'id': 'div_'+id,
|
||||||
|
html: '<li><img src="/images/11887177066.gif" />加载中</li>'
|
||||||
|
}).appendTo('#li_'+id);
|
||||||
|
url="/filelist/sub/uuid/"+uuid+"/subpath/"+id+"/depth/"+depth;
|
||||||
|
$.getJSON(url, function(data) {
|
||||||
|
var items = [];
|
||||||
|
$.each(data, function(key, val) {
|
||||||
|
if(val['filename'].match(/\/$/))
|
||||||
|
{
|
||||||
|
items.push('<li id="li_' + val['id'] + '"><span id="span_'+val['id']+'">+</span> <a href="javascript:;" id="taget_'+val['id']+'" onclick="getSubFileList(\'' +val['uuid']+ '\',\''+val['id']+'\',\''+val['depth']+'\')">' + val['filename'] + '</a></li>');
|
||||||
|
}else{
|
||||||
|
items.push('<li id="' + key + '">' + val['filename'] + '</li>');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$("#div_"+id).html(items.join(''));
|
||||||
|
}).complete(function(){
|
||||||
|
if($("#div_"+id)){
|
||||||
|
$('#span_'+id).html('-');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
//google map
|
||||||
|
var map = new GMap2(document.getElementById("watermap"));
|
||||||
|
var plotbounds=new GLatLngBounds(new GLatLng(<?= $md->south; ?>,<?= $md->west; ?>),new GLatLng(<?= $md->north; ?>,<?= $md->east; ?>));
|
||||||
|
var zoomlevel=map.getBoundsZoomLevel(plotbounds);
|
||||||
|
zoomlevel--;
|
||||||
<?php if ($md->north==$md->south) : ?>
|
<?php if ($md->north==$md->south) : ?>
|
||||||
zoomlevel=10;
|
zoomlevel=10;
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
if (zoomlevel>16) zoomlevel=16;
|
if (zoomlevel>16) zoomlevel=16;
|
||||||
map.setCenter(new GLatLng(<?= ($md->south+$md->north)/2; ?>,<?= ($md->east+$md->west)/2; ?>), zoomlevel);
|
map.setCenter(new GLatLng(<?= ($md->south+$md->north)/2; ?>,<?= ($md->east+$md->west)/2; ?>), zoomlevel);
|
||||||
|
|
Loading…
Reference in New Issue