你的SQL语句放在了哪里?
2012-10-25 16:36 金色海洋(jyk)阳光男孩 阅读(...) 评论(...) 编辑 收藏
这段时间整理自然框架,遇到了一个老问题——SQL语句放在哪里?
对于有规律的比较好办了,但是对于哪些没啥规律的怎么办呢?
想了一下,有几种方式,弄了张图。欢迎大家补充。
因为 有字数限制,必须200字以上。
所以 发一段小代码吧,基于jQuery的拖拽功能。
/*
* 实现拖拽功能。
* $("#divID").drag();// divID:要移动的容器的ID
* $("#divID").drag("spanID");// divID:要移动的容器的ID;spanID:移动是拖拽的对象
*/
jQuery.fn.extend({
drag: function (objDragId, isShowBg) {
var bool = false;
var pageX = 0;
var pageY = 0;
var oldOff = { top: 1, legt: 1 };
var indexMax = $.getDivIndexHighest();
this.each( function () {
var objMove = $( this); // 移动对象
var objDrag = objMove; // 拖拽对象
if (objDragId) objDrag = $("#" + objDragId);
function dragMove(e) {
if (!bool) return;
var x = e.pageX - pageX;
var y = e.pageY - pageY;
var off = { top: 1, legt: 1 }; // oldOff.clone(); // objMove.offset();
off.left = oldOff.left + x;
off.top = oldOff.top + y;
$("#divdrop").offset(off);
}
function drapUp() {
bool = false;
objMove.offset($("#divdrop").offset());
$("#divdrop,#divdropBG").remove();
indexMax = $.getDivIndexHighest();
objMove.css("z-index", indexMax + 1);
if (document.all)
document.onselectstart = new Function("return true");
}
$(document).mousemove( function (e) {
dragMove(e);
}).mouseup( function (e) {
drapUp();
});
objDrag.mouseup(drapUp)
.mousedown( function (e) {
if (document.all)
document.onselectstart = new Function("return false");
objMove.css("z-index", indexMax + 2);
var tmpdiv2 = $("
* 实现拖拽功能。
* $("#divID").drag();// divID:要移动的容器的ID
* $("#divID").drag("spanID");// divID:要移动的容器的ID;spanID:移动是拖拽的对象
*/
jQuery.fn.extend({
drag: function (objDragId, isShowBg) {
var bool = false;
var pageX = 0;
var pageY = 0;
var oldOff = { top: 1, legt: 1 };
var indexMax = $.getDivIndexHighest();
this.each( function () {
var objMove = $( this); // 移动对象
var objDrag = objMove; // 拖拽对象
if (objDragId) objDrag = $("#" + objDragId);
function dragMove(e) {
if (!bool) return;
var x = e.pageX - pageX;
var y = e.pageY - pageY;
var off = { top: 1, legt: 1 }; // oldOff.clone(); // objMove.offset();
off.left = oldOff.left + x;
off.top = oldOff.top + y;
$("#divdrop").offset(off);
}
function drapUp() {
bool = false;
objMove.offset($("#divdrop").offset());
$("#divdrop,#divdropBG").remove();
indexMax = $.getDivIndexHighest();
objMove.css("z-index", indexMax + 1);
if (document.all)
document.onselectstart = new Function("return true");
}
$(document).mousemove( function (e) {
dragMove(e);
}).mouseup( function (e) {
drapUp();
});
objDrag.mouseup(drapUp)
.mousedown( function (e) {
if (document.all)
document.onselectstart = new Function("return false");
objMove.css("z-index", indexMax + 2);
var tmpdiv2 = $("
");
tmpdiv2.attr("id", "divdropBG").html("aaaaaa")
.css("position", "absolute").css("left", 0).css("top", 0)
.width($(document).width()).height($(document).height())
.click(drapUp())
.mousemove( function (e) {
dragMove(e);
})
.css("z-index", indexMax + 1);
var tmpdiv = $("
tmpdiv2.attr("id", "divdropBG").html("aaaaaa")
.css("position", "absolute").css("left", 0).css("top", 0)
.width($(document).width()).height($(document).height())
.click(drapUp())
.mousemove( function (e) {
dragMove(e);
})
.css("z-index", indexMax + 1);
var tmpdiv = $("
");
tmpdiv.html("拖拽中").attr("id", "divdrop")
.css("position", "absolute").css("background-color", "#fff")
.css("opacity", ".60").css("filter", "alpha(opacity=60)/9")
.css("border", "1px solid #99bbe8").css("cursor", "move")
.offset(objMove.offset())
.width(objMove.width()).height(objMove.height())
.mouseup(drapUp)
.css("z-index", indexMax + 3);
// objMove.after(tmpdiv); //.css("position", "absolute");
$(document.body).append(tmpdiv); // .css("position", "absolute");
if (isShowBg)
objMove.after(tmpdiv2);
else {
if ( typeof (isShowBg) == "undefined")
objMove.after(tmpdiv2);
}
bool = true;
pageX = e.pageX;
pageY = e.pageY;
oldOff = objMove.offset();
return false;
})
.mouseover( function () {
objDrag.css("cursor", "move");
});
});
}
});
jQuery.extend({
getDivIndexHighest: function () {
var indexMax = 0;
$("div").each( function () {
var tmp = $( this).css("z-index");
if (tmp != "auto")
if (indexMax < tmp *1)
indexMax = tmp * 1;
});
return indexMax;
}
});
tmpdiv.html("拖拽中").attr("id", "divdrop")
.css("position", "absolute").css("background-color", "#fff")
.css("opacity", ".60").css("filter", "alpha(opacity=60)/9")
.css("border", "1px solid #99bbe8").css("cursor", "move")
.offset(objMove.offset())
.width(objMove.width()).height(objMove.height())
.mouseup(drapUp)
.css("z-index", indexMax + 3);
// objMove.after(tmpdiv); //.css("position", "absolute");
$(document.body).append(tmpdiv); // .css("position", "absolute");
if (isShowBg)
objMove.after(tmpdiv2);
else {
if ( typeof (isShowBg) == "undefined")
objMove.after(tmpdiv2);
}
bool = true;
pageX = e.pageX;
pageY = e.pageY;
oldOff = objMove.offset();
return false;
})
.mouseover( function () {
objDrag.css("cursor", "move");
});
});
}
});
jQuery.extend({
getDivIndexHighest: function () {
var indexMax = 0;
$("div").each( function () {
var tmp = $( this).css("z-index");
if (tmp != "auto")
if (indexMax < tmp *1)
indexMax = tmp * 1;
});
return indexMax;
}
});