You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
191 lines
5.9 KiB
191 lines
5.9 KiB
$(function(){
|
|
var scriptPath = function () {
|
|
var scripts = document.getElementsByTagName('SCRIPT');
|
|
var path = '';
|
|
if(scripts && scripts.length>0) {
|
|
for(var i in scripts) {
|
|
if(path==''){
|
|
var src=scripts[i].src;
|
|
if(src&&/\.js$/.test(src)) {
|
|
path=src.substring(0,src.lastIndexOf("/")+1);
|
|
}
|
|
}else{
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
return path;
|
|
};
|
|
|
|
var JSPATH=scriptPath();
|
|
console.log("JSPATH:"+JSPATH);
|
|
//Enable sidebar toggle
|
|
$("[data-toggle='offcanvas']").click(function(e) {
|
|
e.preventDefault();
|
|
//If window is small enough, enable sidebar push menu
|
|
if ($(window).width() <= 992) {
|
|
$('.row-offcanvas').toggleClass('active');
|
|
$('.left-side').removeClass("collapse-left");
|
|
$(".right-side").removeClass("strech");
|
|
$('.row-offcanvas').toggleClass("relative");
|
|
} else {
|
|
//Else, enable content streching
|
|
$('.left-side').toggleClass("collapse-left");
|
|
$(".right-side").toggleClass("strech");
|
|
}
|
|
});
|
|
|
|
var editorWidget=$("[data-widget='editor']");
|
|
if(editorWidget.length){
|
|
tool.loadScript(JSPATH+"kindeditor/kindeditor-min.js,"+JSPATH+"kindeditor/lang/zh_TW.js",function() {
|
|
KindEditor.ready(function(K) {
|
|
editorWidget.each(function () {
|
|
var id = $(this).attr('id');
|
|
console.log(id);
|
|
if (typeof id != "undefined") {
|
|
var obj="#"+id;
|
|
K.create(obj, {
|
|
resizeType: 1,
|
|
langType : 'zh_TW',
|
|
allowPreviewEmoticons: false,
|
|
allowImageUpload: true,
|
|
items : [
|
|
'fontsize', '|', 'forecolor', 'hilitecolor', 'bold', 'italic', 'underline',
|
|
'removeformat', '|', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist',
|
|
'insertunorderedlist', '|', 'emoticons', 'image', 'link', 'source'],
|
|
afterBlur:function(){this.sync();}
|
|
});
|
|
}
|
|
});
|
|
});
|
|
});
|
|
}
|
|
var dateWidget=$("[data-widget='dateTime']");
|
|
if(dateWidget.length){
|
|
tool.loadScript(JSPATH+"bootstrap-datetimepicker/bootstrap-datetimepicker.min.js,"+JSPATH+"bootstrap-datetimepicker/bootstrap-datetimepicker.min.css",function(){
|
|
dateWidget.each(function() {
|
|
var id=$(this).attr('id');
|
|
var format=$(this).data('format');
|
|
var endDate=$(this).data('enddate');
|
|
if(typeof id!="undefined"){
|
|
tool.date("#"+id,format,endDate);
|
|
}
|
|
});
|
|
});
|
|
}
|
|
var uploadWidget=$("[data-widget='uploadPic']");
|
|
if(uploadWidget.length){
|
|
tool.loadScript(JSPATH+"jquery-ui-1.10.3.min.js,"+JSPATH+"jquery.ui.widget.js,"+JSPATH+"jquery.fileupload.js",function(){
|
|
uploadWidget.each(function() {
|
|
var id=$(this).attr('id');
|
|
var url=$(this).data('url');
|
|
var key=$(this).data('key');
|
|
var img=$(this).data('img');
|
|
if(typeof img!='undefined'){
|
|
tool.showPic("#"+key,img);
|
|
}
|
|
if(typeof id!="undefined"){
|
|
tool.uploadFile(url,"#"+id,"#"+key);
|
|
}
|
|
});
|
|
});
|
|
}
|
|
/*=================================================================*/
|
|
$("#selectAll").each(function(){
|
|
$(this).click(function(event){
|
|
var widget=$(this).data('widget');
|
|
if(typeof widget!='undefined'&&$(widget).length){
|
|
var childs=$(widget).find('.list-checkbox');
|
|
if(childs.length){
|
|
childs.prop('checked', !childs.prop('checked'));
|
|
}
|
|
}
|
|
});
|
|
});
|
|
$("#orderAll").each(function(){
|
|
$(this).click(function(event){
|
|
event.preventDefault();
|
|
var url=$(this).attr("href");
|
|
var widget=$(this).data('widget');
|
|
if(typeof widget!='undefined'&&$(widget).length){
|
|
var childs=$(widget).find('.list-checkbox:checked');
|
|
var checked=[];
|
|
if(childs.length){
|
|
var sortobj=$(widget).find(".input-order");
|
|
childs.each(function(index,child){
|
|
var id=$(this).val();
|
|
//var index=$(this).index();
|
|
var sort=sortobj.eq(index).val();
|
|
if(typeof id!='undefined'&&id&&typeof sort!='undefined'&&sort){
|
|
checked.push(id+"-"+sort);
|
|
}
|
|
});
|
|
if(checked.length){
|
|
var ids=checked.join(',');
|
|
$.post(url,{id:ids},function(data){
|
|
tool.showResponse(data);
|
|
});
|
|
}else{
|
|
tool.msg('請選擇排序項');
|
|
}
|
|
}else{
|
|
tool.msg('請選擇排序項');
|
|
}
|
|
}
|
|
|
|
});
|
|
});
|
|
$("#deleteAll").each(function(){
|
|
$(this).click(function(event){
|
|
event.preventDefault();
|
|
var url=$(this).attr("href");
|
|
|
|
var widget=$(this).data('widget');
|
|
if(typeof widget!='undefined'&&$(widget).length){
|
|
var childs=$(widget).find('.list-checkbox:checked');
|
|
var checked=[];
|
|
if(childs.length){
|
|
childs.each(function(child){
|
|
var id=$(this).val();
|
|
if(typeof id!='undefined')checked.push(id);
|
|
});
|
|
if(checked.length){
|
|
var ids=checked.join(',');
|
|
tool.confirm('確定刪除該紀錄?','刪除操作',0.2,function(){
|
|
$.post(url,{id:ids},function(data){
|
|
tool.showResponse(data);
|
|
});
|
|
});
|
|
}else{
|
|
tool.msg('請選擇刪除項');
|
|
}
|
|
}else{
|
|
tool.msg('請選擇刪除項');
|
|
}
|
|
}
|
|
|
|
|
|
});
|
|
});
|
|
$(".delbtn").each(function(){
|
|
$(this).click(function(event){
|
|
event.preventDefault();
|
|
var url=$(this).attr("href");
|
|
console.log(url);
|
|
tool.confirm('確定刪除該紀錄?','刪除操作',0.2,function(){
|
|
$.get(url,function(data){
|
|
tool.showResponse(data);
|
|
});
|
|
});
|
|
});
|
|
});
|
|
$("#logout").click(function(event){
|
|
event.preventDefault();
|
|
var url=$(this).data("href");
|
|
console.log(url);
|
|
$.get(url,function(data){
|
|
tool.showResponse(data);
|
|
});
|
|
});
|
|
|
|
})
|
|
|