ng-dialog可拖拽

需要jquery-ui.js jquery-2.1.4.js
<script type="text/javascript" src="${pageContext.request.contextPath}/js/libs/jquery/jquery-ui.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/libs/ngdialog/js/ngDialog.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/libs/jquery/jquery-2.1.4.js"></script>


var mockall = angular.module("mockall", [ 'ngDialog', 'ngRoute']);

mockall.config(function ($routeProvider) {
$routeProvider.when("/index", {
templateUrl: contextPath+"/templates/index.html",
controller: "index"
}).otherwise("/index");
});

mockall.controller("index", function ($scope,$http,ngDialog) {
var dubboList = [];
var restList = [];
$scope.editRest = function(index){
var isEdit = false;
var old_url = "";
if(typeof index != 'undefined'){
isEdit = true;
old_url = restList[index].url;
}
ngDialog.editor({
template:contextPath+"/templates/rest-edit.html",
title:isEdit ? "编辑" :"新增" ,
controller:['$scope',function($scope){
$scope.obj = {};
if(isEdit){
$scope.obj = restList[index];
$scope.obj.old_url = old_url;
}else{
$scope.obj.restMethod = "post";
}
$scope.requestHeadersTip = false;
$scope.requestTip = false;
$scope.responseHeadersTip = false;
$scope.responseTip = false;
$scope.submit = function(){
if(!($scope.requestHeadersTip && $scope.requestTip
&& $scope.responseHeadersTip && $scope.responseTip)){
return;
}
console.log(JSON.stringify($scope.obj));
$http({
url: "conf/put_rest",
method: "POST",
data: JSON.stringify($scope.obj),
cache: false
}).success(function(data) {
$scope.closeThisDialog();
$scope.obj = data;
if(data.code == 0){
alert(isEdit ? "更新成功!" :"保存成功!");
queryList("","1",1);
}
});

};

$scope.cancel = function(){
$scope.closeThisDialog();
};

validatorJson = function(jsonStr,name){
$http({
url: "conf/validator",
method: "POST",
data: {"jsonStr":jsonStr.value},
cache: false
}).success(function(data) {
if(data == false){
changeTip(name,true);
}else{
changeTip(name,false);
}
});

};

changeTip = function(name,value){
if(name == "requestHeadersTip"){
$scope.requestHeadersTip = value;
}
if(name == "requestTip"){
$scope.requestTip = value;
}
if(name == "responseHeadersTip"){
$scope.responseHeadersTip = value;
}
if(name == "responseTip"){
$scope.responseTip = value;
}
}
}]
})
};




});


然后在rest-edit.html中

<script>
$(function() {
$(".panel").draggable();
});
</script>

.panel是div的class
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值