$ (function () {
Document.body.className = Localstorage.getitem (' Config-skin ');
$ ("[data-toggle= ' tooltip ']"). ToolTip ();
})
$.reload = function () {
Location.reload ();
return false;
}
$.loading = function (bool, text) {
var $loadingpage = top.$ ("#loadingPage");
var $loadingtext = $loadingpage. Find ('. loading-content ');
if (bool) {
$loadingpage. Show ();
} else {
if ($loadingtext. attr (' istableloading ') = = undefined) {
$loadingpage. Hide ();
}
}
if (!! Text) {
$loadingtext. html (text);
} else {
$loadingtext. HTML ("Data load, please later ...");
}
$loadingtext. CSS ("Left", (top.$ (' body '). Width ()-$loadingtext. Width ())/2-50);
$loadingtext. CSS ("Top", (top.$ (' body '). Height ()-$loadingtext. Height ())/2);
}
$.request = function (name) {
var search = Location.search.slice (1);
var arr = search.split ("&");
for (var i = 0; i < arr.length; i++) {
var ar = arr[i].split ("=");
if (ar[0] = = name) {
if (unescape (ar[1]) = = ' undefined ') {
Return "";
} else {
Return unescape (ar[1]);
}
}
}
Return "";
}
$.currentwindow = function () {
var Iframeid = top.$ (". Nfine_iframe:visible "). attr (" id ");
return Top.frames[iframeid];
}
$.browser = function () {
var useragent = navigator.useragent;
var Isopera = Useragent.indexof ("Opera") >-1;
if (Isopera) {
Return "Opera"
};
if (Useragent.indexof ("Firefox") >-1) {
return "FF";
}
if (Useragent.indexof ("Chrome") >-1) {
if (window.navigator.webkitPersistentStorage.toString (). IndexOf (' Deprecatedstoragequota ') >-1) {
return "Chrome";
} else {
Return "360";
}
}
if (Useragent.indexof ("Safari") >-1) {
return "Safari";
}
if (Useragent.indexof ("compatible") >-1 && useragent.indexof ("MSIE") >-1 &&!isopera) {
return "IE";
};
}
$.download = function (URL, data, method) {
if (URL && data) {
data = typeof data = = ' String '? Data:jQuery.param (data);
var inputs = ';
$.each (Data.split (' & '), function () {
var pair = this.split (' = ');
Inputs + = ' <input type= "hidden" name= "' + pair[0] + '" value= "' + pair[1] + '"/> ';
});
$ (' <form action= "' + URL + '" method= "' + (Method | | ' Post ') + ' > ' + inputs + ' </form> '). AppendTo (' body '). Submit (). remove ();
};
};
$.modalopen = function (options) {
var defaults = {
Id:null,
Title: ' System Window ',
Width: "100px",
Height: "100px",
URL: ",
shade:0.3,
BTN: [' Confirm ', ' close '],
Btnclass: [' btn btn-primary ', ' btn Btn-danger '],
Callback:null
};
var options = $.extend (defaults, options);
var _width = top.$ (window). Width () > parseint (options.width.replace (' px ', '))? options.width:top.$ (window). Width () + ' px ';
var _height = top.$ (window). Height () > parseint (options.height.replace (' px ', '))? options.height:top.$ (window). Height () + ' px ';
Top.layer.open ({
Id:options.id,
Type:2,
Shade:options.shade,
Title:options.title,
Fix:false,
Area: [_width, _height],
Content:options.url,
BTN:OPTIONS.BTN,
Btnclass:options.btnclass,
Yes:function () {
Options.callback (options.id)
}, Cancel:function () {
return true;
}
});
}
$.modalconfirm = function (content, CallBack) {
Top.layer.confirm (content, {
Icon: "Fa-exclamation-circle",
Title: "System Prompt",
BTN: [' Confirm ', ' Cancel '],
Btnclass: [' btn btn-primary ', ' btn Btn-danger '],
}, function () {
CallBack (TRUE);
}, function () {
CallBack (False)
});
}
$.modalalert = function (content, type) {
var icon = "";
if (type = = ' success ') {
icon = "Fa-check-circle";
}
if (type = = ' Error ') {
icon = "Fa-times-circle";
}
if (type = = ' warning ') {
icon = "Fa-exclamation-circle";
}
Top.layer.alert (content, {
Icon:icon,
Title: "System Prompt",
BTN: [' Confirm '],
Btnclass: [' btn btn-primary '],
});
}
$.modalmsg = function (content, type) {
if (type! = undefined) {
var icon = "";
if (type = = ' success ') {
icon = "Fa-check-circle";
}
if (type = = ' Error ') {
icon = "Fa-times-circle";
}
if (type = = ' warning ') {
icon = "Fa-exclamation-circle";
}
Top.layer.msg (content, {Icon:icon, time:4000, shift:5});
Top.$ (". Layui-layer-msg"). Find (' I ' + icon). Parents ('. Layui-layer-msg '). addclass (' layui-layer-msg-' + type);
} else {
Top.layer.msg (content);
}
}
$.modalclose = function () {
var index = Top.layer.getFrameIndex (window.name); Get the index of the current IFRAME layer first
var $IsdialogClose = top.$ ("#layui-layer" + index). Find ('. layui-layer-btn '). Find ("#IsdialogClose");
var isclose = $IsdialogClose. Is (": checked");
if ($IsdialogClose. length = = 0) {
Isclose = true;
}
if (isclose) {
Top.layer.close (index);
} else {
Location.reload ();
}
}
$.submitform = function (options) {
var defaults = {
URL: "",
PARAM: [],
Loading: "Submitting data ...",
Success:null,
Close:true
};
var options = $.extend (defaults, options);
$.loading (True, options.loading);
Window.settimeout (function () {
if ($ (' [Name=__requestverificationtoken] '). Length > 0) {
options.param["__requestverificationtoken"] = $ (' [Name=__requestverificationtoken] '). Val ();
}
$.ajax ({
Url:options.url,
Data:options.param,
Type: "Post",
DataType: "JSON",
Success:function (data) {
if (data.state = = "Success") {
Options.success (data);
$.modalmsg (Data.message, data.state);
if (Options.close = = True) {
$.modalclose ();
}
} else {
$.modalalert (Data.message, data.state);
}
},
Error:function (XMLHttpRequest, Textstatus, Errorthrown) {
$.loading (FALSE);
$.modalmsg (Errorthrown, "error");
},
Beforesend:function () {
$.loading (True, options.loading);
},
Complete:function () {
$.loading (FALSE);
}
});
}, 500);
}
$.deleteform = function (options) {
var defaults = {
Prompt: "Note: Are you sure you want to delete the item data?" ",
URL: "",
PARAM: [],
Loading: "Deleting data ...",
Success:null,
Close:true
};
var options = $.extend (defaults, options);
if ($ (' [Name=__requestverificationtoken] '). Length > 0) {
options.param["__requestverificationtoken"] = $ (' [Name=__requestverificationtoken] '). Val ();
}
$.modalconfirm (options.prompt, function (r) {
if (r) {
$.loading (True, options.loading);
Window.settimeout (function () {
$.ajax ({
Url:options.url,
Data:options.param,
Type: "Post",
DataType: "JSON",
Success:function (data) {
if (data.state = = "Success") {
Options.success (data);
$.modalmsg (Data.message, data.state);
} else {
$.modalalert (Data.message, data.state);
}
},
Error:function (XMLHttpRequest, Textstatus, Errorthrown) {
$.loading (FALSE);
$.modalmsg (Errorthrown, "error");
},
Beforesend:function () {
$.loading (True, options.loading);
},
Complete:function () {
$.loading (FALSE);
}
});
}, 500);
}
});
}
$.jsonwhere = function (data, action) {
if (action = = null) return;
var Reval = new Array ();
$ (data). Each (function (i, v) {
if (Action (v)) {
Reval.push (v);
}
})
return Reval;
}
$.fn.jqgridrowvalue = function () {
var $grid = $ (this);
var selectedrowids = $grid. Jqgrid ("Getgridparam", "Selarrrow");
if (selectedrowids! = "") {
var json = [];
var len = selectedrowids.length;
for (var i = 0; i < len; i++) {
var rowdata = $grid. Jqgrid (' GetRowData ', selectedrowids[i]);
Json.push (RowData);
}
return JSON;
} else {
Return $grid. Jqgrid (' GetRowData ', $grid. Jqgrid (' Getgridparam ', ' Selrow '));
}
}
$.fn.formvalid = function () {
return $ (this). Valid ({
Errorplacement:function (Error, Element) {
Element.parents ('. Formvalue '). addclass (' Has-error ');
Element.parents ('. Has-error '). Find (' I.error '). Remove ();
Element.parents ('. Has-error '). Append (' <i class= "form-control-feedback fa fa-exclamation-circle Error" Data-placement= "left" data-toggle= "tooltip" title= "' + Error + '" ></i> ");
$ ("[data-toggle= ' tooltip ']"). ToolTip ();
if (Element.parents ('. Input-group '). Hasclass (' Input-group ')) {
Element.parents ('. Has-error '). Find (' I.error '). CSS (' right ', ' 33px ')
}
},
Success:function (Element) {
Element.parents ('. Has-error '). Find (' I.error '). Remove ();
Element.parent (). Removeclass (' Has-error ');
}
});
}
$.fn.formserialize = function (formdate) {
var element = $ (this);
if (!! Formdate) {
for (var key in formdate) {
var $id = element.find (' # ' + key);
var value = $.trim (Formdate[key]). Replace (/ /g, ");
var type = $id. attr (' type ');
if ($id. Hasclass ("select2-hidden-accessible")) {
Type = "SELECT";
}
Switch (type) {
Case "checkbox":
if (value = = "true") {
$id. attr ("Checked", ' checked ');
} else {
$id. Removeattr ("checked");
}
Break
Case "SELECT":
$id. val (value). Trigger ("change");
Break
Default
$id. val (value);
Break
}
};
return false;
}
var postdata = {};
Element.find (' Input,select,textarea '). each (function (r) {
var $this = $ (this);
var id = $this. attr (' id ');
var type = $this. attr (' type ');
Switch (type) {
Case "checkbox":
Postdata[id] = $this. Is (": checked");
Break
Default
var value = $this. val () = = ""? " ": $this. Val ();
if (!$.request ("KeyValue")) {
Value = Value.replace (/ /g, ");
}
Postdata[id] = value;
Break
}
});
if ($ (' [Name=__requestverificationtoken] '). Length > 0) {
postdata["__requestverificationtoken"] = $ (' [Name=__requestverificationtoken] '). Val ();
}
return postdata;
};
$.fn.bindselect = function (options) {
var defaults = {
ID: "id",
Text: "Text",
Search:false,
URL: "",
PARAM: [],
Change:null
};
var options = $.extend (defaults, options);
var $element = $ (this);
if (Options.url! = "") {
$.ajax ({
Url:options.url,
Data:options.param,
DataType: "JSON",
Async:false,
Success:function (data) {
$.each (data, function (i) {
$element. Append ($ ("<option></option>"). Val (Data[i][options.id]). HTML (Data[i][options.text]));
});
$element. Select2 ({
MinimumResultsForSearch:options.search = = true? 0:-1
});
$element. On ("Change", function (e) {
if (options.change! = null) {
Options.change (data[$ (this). Find ("option:selected"). Index ()]);
}
$ ("#select2-" + $element. attr (' id ') + "-container"). HTML ($ (this). Find ("option:selected"). Text (). replace (//g, "));
});
}
});
} else {
$element. Select2 ({
Minimumresultsforsearch:-1
});
}
}
$.fn.authorizebutton = function () {
var ModuleID = top.$ (". Nfine_iframe:visible "). attr (" id "). substr (6);
var Datajson = Top.clients.authorizebutton[moduleid];
var $element = $ (this);
$element. Find (' a[authorize=yes] '). attr (' Authorize ', ' no ');
if (Datajson! = undefined) {
$.each (Datajson, function (i) {
$element. Find ("#" + datajson[i]. F_encode). attr (' Authorize ', ' yes ');
});
}
$element. Find ("[Authorize=no]"). Parents (' Li '). Prev ('. Split '). Remove ();
$element. Find ("[Authorize=no]"). Parents (' Li '). Remove ();
$element. Find (' [Authorize=no] '). Remove ();
}
$.fn.datagrid = function (options) {
var defaults = {
DataType: "JSON",
Autowidth:true,
Rownumbers:true,
Shrinktofit:false,
Gridview:true
};
var options = $.extend (defaults, options);
var $element = $ (this);
options["Onselectrow"] = function (ROWID) {
var length = $ (this). Jqgrid ("Getgridparam", "Selrow"). Length;
var $operate = $ (". Operate");
if (length > 0) {
$operate. Animate ({"Left": 0}, 200);
} else {
$operate. Animate ({"Left": '-100.1% '}, 200);
}
$operate. Find ('. Close '). Click (function () {
$operate. Animate ({"Left": '-100.1% '}, 200);
})
};
$element. Jqgrid (options);
};
The framework-ui.js of two-dimensional code JS