#408 封装inputbg,loadinglayer插件,增加联系人自动提示功能
This commit is contained in:
parent
2d32af9077
commit
11dd20a220
|
@ -3597,7 +3597,7 @@ class AuthorController extends Zend_Controller_Action
|
|||
{
|
||||
if(isset($v['Required']) && $v['Required'] == true)
|
||||
{
|
||||
if($v['Type'] == 'varchar')
|
||||
if($v['Type'] == 'varchar' || $v['Type'] == 'text')
|
||||
{
|
||||
if(empty($data[$v['FieldName_temp']]))
|
||||
{
|
||||
|
@ -3681,9 +3681,11 @@ class AuthorController extends Zend_Controller_Action
|
|||
{
|
||||
if(!empty($commit))
|
||||
{
|
||||
$data = array("uuid"=>$rs,"submit"=>$commit);
|
||||
$data = array("uuid"=>$rs,"complete"=>$commit);
|
||||
}else{
|
||||
$data = array("uuid"=>$rs,'saved'=>1);
|
||||
}
|
||||
$this->jsonexit(array("uuid"=>$rs));
|
||||
$this->jsonexit($data);
|
||||
return true;
|
||||
}else{
|
||||
$this->jsonexit(array("error"=>'保存失败'));
|
||||
|
@ -3691,6 +3693,25 @@ class AuthorController extends Zend_Controller_Action
|
|||
}
|
||||
}// 新元数据保存
|
||||
|
||||
if($ac == "autoinput")
|
||||
{
|
||||
$this->_helper->layout->disableLayout();
|
||||
$this->_helper->viewRenderer->setNoRender();
|
||||
|
||||
$name = $this->_getParam('k');
|
||||
|
||||
$name = strip_tags(trim($name));
|
||||
|
||||
if(!empty($name))
|
||||
{
|
||||
$sql = "SELECT realname,email FROM users WHERE realname LIKE ? OR email LIKE ?";
|
||||
$sth = $this->db->prepare($sql);
|
||||
$sth->execute(array('%'.$name.'%','%'.$name.'%'));
|
||||
$rows = $sth->fetchAll();
|
||||
$this->jsonexit($rows);
|
||||
}
|
||||
}
|
||||
|
||||
if($ac == "process")
|
||||
{
|
||||
$this->_helper->layout->disableLayout();
|
||||
|
|
|
@ -7,6 +7,8 @@ $this->theme->AppendPlus($this,'jquery_ui');
|
|||
$this->theme->AppendPlus($this,'google_map_v3');
|
||||
$this->theme->AppendPlus($this,'google_map_keydragzone');
|
||||
$this->theme->AppendPlus($this,'colorbox');
|
||||
$this->theme->AppendPlus($this,'inputbg');
|
||||
$this->theme->AppendPlus($this,'loadinglayer');
|
||||
$this->headLink()->appendStylesheet('/css/author.css');
|
||||
$this->headLink()->appendStylesheet('/css/author-metadata.css');
|
||||
$this->breadcrumb('<a href="/">首页</a>');
|
||||
|
@ -185,8 +187,8 @@ $this->breadcrumb()->setSeparator(' > ');
|
|||
$index++ ;?>
|
||||
<div class="control-group control-group-contact" id="contact_1st">
|
||||
<div class="controls">
|
||||
<input type="text" name="<?= $F['contact'] ?>[<?= $index ?>][name]" class="span3" value="<?= $v->name ?>" />
|
||||
<input type="text" name="<?= $F['contact'] ?>[<?= $index ?>][email]" class="span3" value="<?= $v->email ?>" />
|
||||
<input type="text" name="<?= $F['contact'] ?>[<?= $index ?>][name]" class="span3 contact_name" value="<?= $v->name ?>" />
|
||||
<input type="text" name="<?= $F['contact'] ?>[<?= $index ?>][email]" class="span3 contact_email" value="<?= $v->email ?>" />
|
||||
<select type="text" name="<?= $F['contact'] ?>[<?= $index ?>][type]" class="span3">
|
||||
<option value="0">请选择联系人职能</option>
|
||||
<?php
|
||||
|
@ -207,8 +209,8 @@ $this->breadcrumb()->setSeparator(' > ');
|
|||
}else{ ?>
|
||||
<div class="control-group control-group-contact" id="contact_1st">
|
||||
<div class="controls">
|
||||
<input type="text" name="<?= $F['contact'] ?>[1][name]" class="span3 contact_name" value="" />
|
||||
<input type="text" name="<?= $F['contact'] ?>[1][email]" class="span3 contact_email" value="" />
|
||||
<input type="text" name="<?= $F['contact'] ?>[1][name]" class="span3 contact_name" />
|
||||
<input type="text" name="<?= $F['contact'] ?>[1][email]" class="span3 contact_email" />
|
||||
<select type="text" name="<?= $F['contact'] ?>[1][type]" class="span3">
|
||||
<option value="0">请选择联系人职能</option>
|
||||
<?php
|
||||
|
@ -228,8 +230,8 @@ $this->breadcrumb()->setSeparator(' > ');
|
|||
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<button type="button" onclick="save(0)" class="btn btn-green">保存草稿</button>
|
||||
<button type="button" onclick="save(1)" class="btn btn-green">提交元数据</button>
|
||||
<button type="button" onclick="save(0,this)" class="btn btn-green">保存草稿</button>
|
||||
<button type="button" onclick="save(1,this)" class="btn btn-green">提交元数据</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -267,7 +269,23 @@ function getValue(){
|
|||
return $('#metadata_temp_value').serialize();
|
||||
}
|
||||
|
||||
function save(s){
|
||||
function prepare(){
|
||||
$('.contact_email').each(function(index, element) {
|
||||
if($(this).val()=='Email')
|
||||
{
|
||||
$(this).val('');
|
||||
}
|
||||
});
|
||||
$('.contact_name').each(function(index, element) {
|
||||
if($(this).val()=='姓名')
|
||||
{
|
||||
$(this).val('');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function save(s,btn){
|
||||
prepare();
|
||||
var postdata = "";
|
||||
if(s>0)
|
||||
{
|
||||
|
@ -286,10 +304,14 @@ function save(s){
|
|||
{Alert(data.error);}
|
||||
if(typeof(data.deleted)!='undefined')
|
||||
{$('#list_'+data.deleted).fadeOut("slow",function(){$(this).remove();});}
|
||||
if(typeof(data.complete) != 'underfined')
|
||||
if(typeof(data.complete) != 'undefined')
|
||||
{
|
||||
self.location='/author/metadata/';
|
||||
}
|
||||
if(typeof(data.saved) != 'undefined')
|
||||
{
|
||||
Alert('保存成功');
|
||||
}
|
||||
if(typeof(data.uuid)!='undefined')
|
||||
{
|
||||
$('#temp_uuid').val(data.uuid);$('#form_part_b').css('display','block');$('#next_step_button').hide();initialize()
|
||||
|
@ -302,9 +324,107 @@ function save(s){
|
|||
'timeout': 30000,
|
||||
'error': function(){
|
||||
$.colorbox({'innerWidth':'50%','html':'<img src="/images/alert_big_error.png" /><h4>处理中出现错误,请刷新页面后重试</h4>'});
|
||||
}
|
||||
},
|
||||
'beforeSend':function(){
|
||||
$(btn).parent('div').loadinglayer('show');
|
||||
},
|
||||
'complete':function(){
|
||||
$(btn).parent('div').loadinglayer('hide');
|
||||
}
|
||||
});
|
||||
postdata = null;
|
||||
}
|
||||
|
||||
function AutoComplete(input)
|
||||
{
|
||||
if($('#auto-complete-elements').length > 0)
|
||||
{
|
||||
$('#auto-complete-elements').remove();
|
||||
}
|
||||
var postdata = "";
|
||||
if(($(input).val()!='Email' && $(input).val()!='姓名') && $(input).val()!='')
|
||||
{
|
||||
postdata = 'ac=autoinput&k=' + $(input).val();
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
$.ajax({
|
||||
'type':"POST",
|
||||
'url':'/author/metadata/',
|
||||
'data': postdata,
|
||||
'success':function(data){
|
||||
if (typeof(data)=='object')
|
||||
{
|
||||
if(data.length>0)
|
||||
{
|
||||
AutoCompleteInit(data,input)
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else{
|
||||
return false;
|
||||
}
|
||||
},
|
||||
'timeout': 30000,
|
||||
'error': function(){
|
||||
$.colorbox({'innerWidth':'50%','html':'<img src="/images/alert_big_error.png" /><h4>处理中出现错误,请刷新页面后重试</h4>'});
|
||||
},
|
||||
'beforeSend':function(){
|
||||
$(input).parent('div').loadinglayer('show');
|
||||
},
|
||||
'complete':function(){
|
||||
$(input).parent('div').loadinglayer('hide');
|
||||
}
|
||||
});
|
||||
}
|
||||
function AutoCompleteInit(data,input)
|
||||
{
|
||||
var id = "auto-complete-elements";
|
||||
var dom = '#'+id;
|
||||
var html = AutoCompleteElement(data);
|
||||
$(input).parent('div').append(html);
|
||||
var f_left = $(input).position().left;
|
||||
console.log($(input).position().top);
|
||||
if($(input).position().top < $('body').height())
|
||||
{
|
||||
var f_top = $(input).position().top + $(input).height() + 5;
|
||||
}else{
|
||||
var f_top = $(input).position().top - $(input).height() - 140;
|
||||
}
|
||||
$(dom).css({left:f_left,top:f_top});
|
||||
$(dom).children('ul').children('li').each(function(index, element) {
|
||||
$(this).bind('click',function(){
|
||||
var d = $(this).attr('rel');
|
||||
var b = $(this).attr('bre');
|
||||
$(input).parent('div').children('input').each(function(index, element) {
|
||||
if($(this).hasClass('contact_name'))
|
||||
{
|
||||
$(this).val(d);
|
||||
}
|
||||
if($(this).hasClass('contact_email'))
|
||||
{
|
||||
$(this).val(b);
|
||||
}
|
||||
});
|
||||
$(dom).remove();
|
||||
});
|
||||
});
|
||||
$(dom).children('.close-btn').bind('click',function(){
|
||||
$(dom).remove();
|
||||
});
|
||||
}
|
||||
function AutoCompleteElement(data)
|
||||
{
|
||||
var id = "auto-complete-elements";
|
||||
var head = '<div class="auto-complete-elements" id="'+ id +'"><ul>';
|
||||
var foot = '</ul><div class="close-btn">[x] 关闭</div></div>';
|
||||
var inner = "";
|
||||
for(i in data)
|
||||
{
|
||||
inner += '<li rel="'+ data[i].realname + '" bre="'+ data[i].email +'">' + data[i].realname +'('+data[i].email+')</li>';
|
||||
}
|
||||
var html = head + inner + foot;
|
||||
return html;
|
||||
}
|
||||
|
||||
// Metadata Commit Part --End
|
||||
|
@ -348,45 +468,23 @@ function SelectInputTemplate(name){
|
|||
+ '</div>';
|
||||
now_index = null;
|
||||
index = null;
|
||||
|
||||
return html;
|
||||
}
|
||||
}
|
||||
|
||||
(function( $ ){
|
||||
|
||||
$.fn.inputbg = function( options ) {
|
||||
|
||||
// Create some defaults, extending them with any options that were provided
|
||||
var settings = $.extend( {
|
||||
val : '姓名'
|
||||
}, options);
|
||||
|
||||
this.each(function() {
|
||||
if($(this).val() == '')
|
||||
{
|
||||
$(this).val(options.val);
|
||||
}
|
||||
});
|
||||
|
||||
this.bind('focus',function(){
|
||||
if($(this).val() == options.val)
|
||||
{
|
||||
$(this).val('');
|
||||
}
|
||||
});
|
||||
this.bind('blur',function(){
|
||||
if($(this).val() == '')
|
||||
{
|
||||
$(this).val(options.val);
|
||||
}
|
||||
});
|
||||
|
||||
};
|
||||
})( jQuery );
|
||||
|
||||
function InputTextSet(){
|
||||
console.log($('.contact_name').length);
|
||||
$('.contact_name').inputbg({'val':'姓名'});
|
||||
$('.contact_email').inputbg({'val':'Email'});
|
||||
$('.contact_name').each(function(index, element) {
|
||||
$(this).bind('change',function(){
|
||||
if($(this).val() != '')
|
||||
{
|
||||
AutoComplete(this);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// Google Map Part
|
||||
|
@ -431,6 +529,8 @@ function initialize() {
|
|||
setRectangle(latlng.ca.d,latlng.ca.b,latlng.Z.b,latlng.Z.d);
|
||||
//console.dir(latlng);
|
||||
});
|
||||
|
||||
InputValueChange();
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -51,9 +51,23 @@ class Theme
|
|||
$this->CSSKey => array(
|
||||
'/js/lib/jquery.colorbox/style2/colorbox.css'
|
||||
)
|
||||
),
|
||||
),
|
||||
|
||||
//inputbg
|
||||
'inputbg' => array(
|
||||
$this->ScriptKey => array(
|
||||
'/js/lib/custom/jquery.inputbg.js'
|
||||
)
|
||||
),
|
||||
|
||||
//loadinglayer
|
||||
'loadinglayer' => array(
|
||||
$this->ScriptKey => array(
|
||||
'/js/lib/custom/jquery.loadinglayer.js'
|
||||
)
|
||||
),
|
||||
|
||||
|
||||
/*********谷歌地图*********/
|
||||
|
||||
//Google Map API v3
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
// JavaScript Document
|
||||
(function( $ ){
|
||||
|
||||
$.fn.inputbg = function( options ) {
|
||||
|
||||
var settings = $.extend( {
|
||||
val : '姓名'
|
||||
}, options);
|
||||
|
||||
this.each(function() {
|
||||
if($(this).val() == '')
|
||||
{
|
||||
$(this).val(options.val);
|
||||
}
|
||||
console.log($(this).attr('name'));
|
||||
$(this).bind('focus',function(){
|
||||
if($(this).val() == options.val)
|
||||
{
|
||||
$(this).val('');
|
||||
}
|
||||
});
|
||||
$(this).bind('blur',function(){
|
||||
if($(this).val() == '')
|
||||
{
|
||||
$(this).val(options.val);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
};
|
||||
})( jQuery );
|
|
@ -0,0 +1,31 @@
|
|||
// JavaScript Document
|
||||
(function( $ ){
|
||||
|
||||
var methods = {
|
||||
show : function( ) {
|
||||
var id = "getcategory-ajax-loading-dom";
|
||||
var loadingdiv = '<span id="'+ id +'"><img src="/images/ajax-load-small.gif" /></div>';
|
||||
$(this).append(loadingdiv);
|
||||
},
|
||||
hide : function( ) {
|
||||
if($('#getcategory-ajax-loading-dom').length > 0)
|
||||
{
|
||||
$('#getcategory-ajax-loading-dom').remove();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
$.fn.loadinglayer = function( method ) {
|
||||
|
||||
// Method calling logic
|
||||
if ( methods[method] ) {
|
||||
return methods[ method ].apply( this, Array.prototype.slice.call( arguments, 1 ));
|
||||
} else if ( typeof method === 'object' || ! method ) {
|
||||
return methods.init.apply( this, arguments );
|
||||
} else {
|
||||
$.error( 'Method ' + method + ' does not exist' );
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
})( jQuery );
|
Loading…
Reference in New Issue