[Frontend][系統監控] 調整為卡片式呈現
This commit is contained in:
parent
bcb07e0054
commit
36e64f8eac
@ -14,15 +14,15 @@
|
|||||||
<div class="col-sm-12 col-xl-5">
|
<div class="col-sm-12 col-xl-5">
|
||||||
<div class="d-flex mb-4" style="gap:15px">
|
<div class="d-flex mb-4" style="gap:15px">
|
||||||
<div class="row m-0 align-items-center">
|
<div class="row m-0 align-items-center">
|
||||||
<span id="sysNorLight" class="circle-light mr-2"></span>
|
<span id="sysNorLight" class="circle-light mr-2 " data-light-type="normal"></span>
|
||||||
<label class="mb-0">正常</label>
|
<label class="mb-0">正常</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="row m-0 align-items-center">
|
<div class="row m-0 align-items-center">
|
||||||
<span id="sysCloLight" class="circle-light mr-2"></span>
|
<span id="sysCloLight" class="circle-light mr-2" data-light-type="close"></span>
|
||||||
<label class="mb-0">關機</label>
|
<label class="mb-0">關機</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="row m-0 align-items-center">
|
<div class="row m-0 align-items-center">
|
||||||
<span id="sysErrLight" class="circle-light mr-2"></span>
|
<span id="sysErrLight" class="circle-light mr-2" data-light-type="error"></span>
|
||||||
<label class="mb-0">異常</label>
|
<label class="mb-0">異常</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -49,25 +49,44 @@
|
|||||||
|
|
||||||
$(function () {
|
$(function () {
|
||||||
getFloDevList();
|
getFloDevList();
|
||||||
loadStaLight();
|
setLightColor();
|
||||||
})
|
})
|
||||||
|
|
||||||
function loadStaLight() {
|
//function loadStaLight() {
|
||||||
if (pageAct.sysSubObj.device_normal_color) {
|
// if (pageAct.sysSubObj.device_normal_color) {
|
||||||
$("#sysNorLight").css("background-color", pageAct.sysSubObj.device_normal_color);
|
// $("#sysNorLight").css("background-color", pageAct.sysSubObj.device_normal_color);
|
||||||
} else {
|
// } else {
|
||||||
$("#sysNorLight").addClass("bg-success");
|
// $("#sysNorLight").addClass("bg-success");
|
||||||
}
|
// }
|
||||||
if (pageAct.sysSubObj.device_close_color) {
|
// if (pageAct.sysSubObj.device_close_color) {
|
||||||
$("#sysCloLight").css("background-color", pageAct.sysSubObj.device_close_color);
|
// $("#sysCloLight").css("background-color", pageAct.sysSubObj.device_close_color);
|
||||||
} else {
|
// } else {
|
||||||
$("#sysCloLight").addClass("bg-secondary");
|
// $("#sysCloLight").addClass("bg-secondary");
|
||||||
}
|
// }
|
||||||
if (pageAct.sysSubObj.device_error_color) {
|
// if (pageAct.sysSubObj.device_error_color) {
|
||||||
$("#sysErrLight").css("background-color", pageAct.sysSubObj.device_error_color);
|
// $("#sysErrLight").css("background-color", pageAct.sysSubObj.device_error_color);
|
||||||
} else {
|
// } else {
|
||||||
$("#sysErrLight").addClass("bg-danger");
|
// $("#sysErrLight").addClass("bg-danger");
|
||||||
}
|
// }
|
||||||
|
//}
|
||||||
|
|
||||||
|
function setLightColor() {
|
||||||
|
$("[data-light-type]").each((index, ele) => {
|
||||||
|
let type = $(ele).data("light-type");
|
||||||
|
let color = "#000";
|
||||||
|
switch (type) {
|
||||||
|
case "normal":
|
||||||
|
color = pageAct.sysSubObj.device_normal_color ?? "var(--theme-success)";
|
||||||
|
break;
|
||||||
|
case "close":
|
||||||
|
color = pageAct.sysSubObj.device_close_color ?? "var(--theme-secondary)";
|
||||||
|
break;
|
||||||
|
case "error":
|
||||||
|
color = pageAct.sysSubObj.device_error_color ?? "var(--theme-danger)";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
$(ele).css("background-color", color);
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function getFloDevList() {
|
function getFloDevList() {
|
||||||
@ -84,15 +103,28 @@
|
|||||||
} else {
|
} else {
|
||||||
let strHtml = ``;
|
let strHtml = ``;
|
||||||
$.each(res.data, (index, floObj) => {
|
$.each(res.data, (index, floObj) => {
|
||||||
strHtml += `<div class='d-flex justify-content-start mb-5' style="height:60px">`
|
strHtml += `<div class='d-flex justify-content-start mb-5' style="">`
|
||||||
strHtml += `<button id="floItemBtn${floObj.full_name}" type="button" class="btn btn-primary waves-effect waves-themed mr-5 align-self-center" >${floObj.full_name}</button>`
|
strHtml += `<button id="floItemBtn${floObj.full_name}" type="button" class="btn btn-primary waves-effect waves-themed mr-5 align-self-center" >${floObj.full_name}</button>`
|
||||||
|
|
||||||
$.each(floObj.device_list, (index2, devObj) => {
|
$.each(floObj.device_list, (index2, devObj) => {
|
||||||
console.log(">>>> url: " + baseImgUrl + " , img: " + varPathImg + ", icon: " + devObj.device_master_icon);
|
console.log(">>>> url: " + baseImgUrl + " , img: " + varPathImg + ", icon: " + devObj.device_master_icon);
|
||||||
strHtml += `<div name="devItem" data-id="${devObj.device_guid}" data-number="${devObj.device_number}" data-name="${devObj.full_name}" class="mr-5 cur-poi">
|
|
||||||
<span class="status status-success d-inline-block">
|
strHtml += `<div class="card m-1 border device-wrap" style="width:300px">
|
||||||
<img src="${baseImgUrl + varPathImg + devObj.device_master_icon}" class="profile-image rounded-circle" onerror="defDev(this)" alt="...">
|
<div class="card-body p-2">
|
||||||
</span> ${devObj.full_name}
|
<div class="d-flex mb-2">
|
||||||
|
<div class="mr-5 cur-poi">
|
||||||
|
<span class="d-inline-block mr-3">
|
||||||
|
<img src="${baseImgUrl + varPathImg + devObj.device_master_icon}" class="profile-image rounded-circle" onerror="defDev(this)" alt="...">
|
||||||
|
</span>
|
||||||
|
<a href="javascript:;">${devObj.full_name}</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="d-flex mb-0 mt-2 align-items-center">
|
||||||
|
<span id="${devObj.device_number}_status" class="circle-light" data-light-type="normal"></span>
|
||||||
|
<span class="d-none">即時功率:</span>
|
||||||
|
<a href="javascript:;" name="devItem" data-id="${devObj.device_guid}" data-number="${devObj.device_number}" data-name="${devObj.full_name}" class=" ml-2 mb-0 ">詳細資料</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>`;
|
</div>`;
|
||||||
})
|
})
|
||||||
strHtml += "</div>"
|
strHtml += "</div>"
|
||||||
@ -163,7 +195,11 @@
|
|||||||
let devName = $(ele).data("name"); //full_name
|
let devName = $(ele).data("name"); //full_name
|
||||||
$(ele).YTTooltip({
|
$(ele).YTTooltip({
|
||||||
html: `<div class="card m-1 border device-wrap">
|
html: `<div class="card m-1 border device-wrap">
|
||||||
|
<div class="col-12 p-0 row justify-content-end m-0">
|
||||||
|
<button class="btn p-2"><i class="fas fa-times fs-1 text-white-50" data-close="yttooltip"></i></button>
|
||||||
|
</div>
|
||||||
<div class="card-header p-2 px-3">
|
<div class="card-header p-2 px-3">
|
||||||
|
|
||||||
<div class="position-absolute w-50" style="word-break: break-all;">
|
<div class="position-absolute w-50" style="word-break: break-all;">
|
||||||
<label class="m-0 mt-2">${devName}</label>
|
<label class="m-0 mt-2">${devName}</label>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
* FileSaver.js
|
* FileSaver.js
|
||||||
* A saveAs() FileSaver implementation.
|
* A saveAs() FileSaver implementation.
|
||||||
*
|
*
|
||||||
@ -11,59 +11,59 @@
|
|||||||
// The one and only way of getting global scope in all environments
|
// The one and only way of getting global scope in all environments
|
||||||
// https://stackoverflow.com/q/3277182/1008999
|
// https://stackoverflow.com/q/3277182/1008999
|
||||||
var _global = typeof window === 'object' && window.window === window
|
var _global = typeof window === 'object' && window.window === window
|
||||||
? window : typeof self === 'object' && self.self === self
|
? window : typeof self === 'object' && self.self === self
|
||||||
? self : typeof global === 'object' && global.global === global
|
? self : typeof global === 'object' && global.global === global
|
||||||
? global
|
? global
|
||||||
: this
|
: this
|
||||||
|
|
||||||
function bom(blob, opts) {
|
function bom (blob, opts) {
|
||||||
if (typeof opts === 'undefined') opts = { autoBom: false }
|
if (typeof opts === 'undefined') opts = { autoBom: false }
|
||||||
else if (typeof opts !== 'object') {
|
else if (typeof opts !== 'object') {
|
||||||
console.warn('Deprecated: Expected third argument to be a object')
|
console.warn('Deprecated: Expected third argument to be a object')
|
||||||
opts = { autoBom: !opts }
|
opts = { autoBom: !opts }
|
||||||
}
|
}
|
||||||
|
|
||||||
// prepend BOM for UTF-8 XML and text/* types (including HTML)
|
// prepend BOM for UTF-8 XML and text/* types (including HTML)
|
||||||
// note: your browser will automatically convert UTF-16 U+FEFF to EF BB BF
|
// note: your browser will automatically convert UTF-16 U+FEFF to EF BB BF
|
||||||
if (opts.autoBom && /^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(blob.type)) {
|
if (opts.autoBom && /^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(blob.type)) {
|
||||||
return new Blob([String.fromCharCode(0xFEFF), blob], { type: blob.type })
|
return new Blob([String.fromCharCode(0xFEFF), blob], { type: blob.type })
|
||||||
}
|
}
|
||||||
return blob
|
return blob
|
||||||
}
|
}
|
||||||
|
|
||||||
function download(url, name, opts) {
|
function download (url, name, opts) {
|
||||||
var xhr = new XMLHttpRequest()
|
var xhr = new XMLHttpRequest()
|
||||||
xhr.open('GET', url)
|
xhr.open('GET', url)
|
||||||
xhr.responseType = 'blob'
|
xhr.responseType = 'blob'
|
||||||
xhr.onload = function () {
|
xhr.onload = function () {
|
||||||
saveAs(xhr.response, name, opts)
|
saveAs(xhr.response, name, opts)
|
||||||
}
|
}
|
||||||
xhr.onerror = function () {
|
xhr.onerror = function () {
|
||||||
console.error('could not download file')
|
console.error('could not download file')
|
||||||
}
|
}
|
||||||
|
xhr.send()
|
||||||
|
}
|
||||||
|
|
||||||
|
function corsEnabled (url) {
|
||||||
|
var xhr = new XMLHttpRequest()
|
||||||
|
// use sync to avoid popup blocker
|
||||||
|
xhr.open('HEAD', url, false)
|
||||||
|
try {
|
||||||
xhr.send()
|
xhr.send()
|
||||||
}
|
} catch (e) {}
|
||||||
|
return xhr.status >= 200 && xhr.status <= 299
|
||||||
function corsEnabled(url) {
|
|
||||||
var xhr = new XMLHttpRequest()
|
|
||||||
// use sync to avoid popup blocker
|
|
||||||
xhr.open('HEAD', url, false)
|
|
||||||
try {
|
|
||||||
xhr.send()
|
|
||||||
} catch (e) { }
|
|
||||||
return xhr.status >= 200 && xhr.status <= 299
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// `a.click()` doesn't work for all browsers (#465)
|
// `a.click()` doesn't work for all browsers (#465)
|
||||||
function click(node) {
|
function click (node) {
|
||||||
try {
|
try {
|
||||||
node.dispatchEvent(new MouseEvent('click'))
|
node.dispatchEvent(new MouseEvent('click'))
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
var evt = document.createEvent('MouseEvents')
|
var evt = document.createEvent('MouseEvents')
|
||||||
evt.initMouseEvent('click', true, true, window, 0, 0, 0, 80,
|
evt.initMouseEvent('click', true, true, window, 0, 0, 0, 80,
|
||||||
20, false, false, false, false, 0, null)
|
20, false, false, false, false, 0, null)
|
||||||
node.dispatchEvent(evt)
|
node.dispatchEvent(evt)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Detect WebView inside a native macOS app by ruling out all browsers
|
// Detect WebView inside a native macOS app by ruling out all browsers
|
||||||
@ -72,100 +72,100 @@ function click(node) {
|
|||||||
var isMacOSWebView = _global.navigator && /Macintosh/.test(navigator.userAgent) && /AppleWebKit/.test(navigator.userAgent) && !/Safari/.test(navigator.userAgent)
|
var isMacOSWebView = _global.navigator && /Macintosh/.test(navigator.userAgent) && /AppleWebKit/.test(navigator.userAgent) && !/Safari/.test(navigator.userAgent)
|
||||||
|
|
||||||
var saveAs = _global.saveAs || (
|
var saveAs = _global.saveAs || (
|
||||||
// probably in some web worker
|
// probably in some web worker
|
||||||
(typeof window !== 'object' || window !== _global)
|
(typeof window !== 'object' || window !== _global)
|
||||||
? function saveAs() { /* noop */ }
|
? function saveAs () { /* noop */ }
|
||||||
|
|
||||||
// Use download attribute first if possible (#193 Lumia mobile) unless this is a macOS WebView
|
// Use download attribute first if possible (#193 Lumia mobile) unless this is a macOS WebView
|
||||||
: ('download' in HTMLAnchorElement.prototype && !isMacOSWebView)
|
: ('download' in HTMLAnchorElement.prototype && !isMacOSWebView)
|
||||||
? function saveAs(blob, name, opts) {
|
? function saveAs (blob, name, opts) {
|
||||||
var URL = _global.URL || _global.webkitURL
|
var URL = _global.URL || _global.webkitURL
|
||||||
var a = document.createElement('a')
|
var a = document.createElement('a')
|
||||||
name = name || blob.name || 'download'
|
name = name || blob.name || 'download'
|
||||||
|
|
||||||
a.download = name
|
a.download = name
|
||||||
a.rel = 'noopener' // tabnabbing
|
a.rel = 'noopener' // tabnabbing
|
||||||
|
|
||||||
// TODO: detect chrome extensions & packaged apps
|
// TODO: detect chrome extensions & packaged apps
|
||||||
// a.target = '_blank'
|
// a.target = '_blank'
|
||||||
|
|
||||||
if (typeof blob === 'string') {
|
if (typeof blob === 'string') {
|
||||||
// Support regular links
|
// Support regular links
|
||||||
a.href = blob
|
a.href = blob
|
||||||
if (a.origin !== location.origin) {
|
if (a.origin !== location.origin) {
|
||||||
corsEnabled(a.href)
|
corsEnabled(a.href)
|
||||||
? download(blob, name, opts)
|
? download(blob, name, opts)
|
||||||
: click(a, a.target = '_blank')
|
: click(a, a.target = '_blank')
|
||||||
} else {
|
} else {
|
||||||
click(a)
|
click(a)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Support blobs
|
// Support blobs
|
||||||
a.href = URL.createObjectURL(blob)
|
a.href = URL.createObjectURL(blob)
|
||||||
setTimeout(function () { URL.revokeObjectURL(a.href) }, 4E4) // 40s
|
setTimeout(function () { URL.revokeObjectURL(a.href) }, 4E4) // 40s
|
||||||
setTimeout(function () { click(a) }, 0)
|
setTimeout(function () { click(a) }, 0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Use msSaveOrOpenBlob as a second approach
|
// Use msSaveOrOpenBlob as a second approach
|
||||||
: 'msSaveOrOpenBlob' in navigator
|
: 'msSaveOrOpenBlob' in navigator
|
||||||
? function saveAs(blob, name, opts) {
|
? function saveAs (blob, name, opts) {
|
||||||
name = name || blob.name || 'download'
|
name = name || blob.name || 'download'
|
||||||
|
|
||||||
if (typeof blob === 'string') {
|
if (typeof blob === 'string') {
|
||||||
if (corsEnabled(blob)) {
|
if (corsEnabled(blob)) {
|
||||||
download(blob, name, opts)
|
download(blob, name, opts)
|
||||||
} else {
|
} else {
|
||||||
var a = document.createElement('a')
|
var a = document.createElement('a')
|
||||||
a.href = blob
|
a.href = blob
|
||||||
a.target = '_blank'
|
a.target = '_blank'
|
||||||
setTimeout(function () { click(a) })
|
setTimeout(function () { click(a) })
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
navigator.msSaveOrOpenBlob(bom(blob, opts), name)
|
navigator.msSaveOrOpenBlob(bom(blob, opts), name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fallback to using FileReader and a popup
|
// Fallback to using FileReader and a popup
|
||||||
: function saveAs(blob, name, opts, popup) {
|
: function saveAs (blob, name, opts, popup) {
|
||||||
// Open a popup immediately do go around popup blocker
|
// Open a popup immediately do go around popup blocker
|
||||||
// Mostly only available on user interaction and the fileReader is async so...
|
// Mostly only available on user interaction and the fileReader is async so...
|
||||||
popup = popup || open('', '_blank')
|
popup = popup || open('', '_blank')
|
||||||
if (popup) {
|
if (popup) {
|
||||||
popup.document.title =
|
popup.document.title =
|
||||||
popup.document.body.innerText = 'downloading...'
|
popup.document.body.innerText = 'downloading...'
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof blob === 'string') return download(blob, name, opts)
|
if (typeof blob === 'string') return download(blob, name, opts)
|
||||||
|
|
||||||
var force = blob.type === 'application/octet-stream'
|
var force = blob.type === 'application/octet-stream'
|
||||||
var isSafari = /constructor/i.test(_global.HTMLElement) || _global.safari
|
var isSafari = /constructor/i.test(_global.HTMLElement) || _global.safari
|
||||||
var isChromeIOS = /CriOS\/[\d]+/.test(navigator.userAgent)
|
var isChromeIOS = /CriOS\/[\d]+/.test(navigator.userAgent)
|
||||||
|
|
||||||
if ((isChromeIOS || (force && isSafari) || isMacOSWebView) && typeof FileReader !== 'undefined') {
|
if ((isChromeIOS || (force && isSafari) || isMacOSWebView) && typeof FileReader !== 'undefined') {
|
||||||
// Safari doesn't allow downloading of blob URLs
|
// Safari doesn't allow downloading of blob URLs
|
||||||
var reader = new FileReader()
|
var reader = new FileReader()
|
||||||
reader.onloadend = function () {
|
reader.onloadend = function () {
|
||||||
var url = reader.result
|
var url = reader.result
|
||||||
url = isChromeIOS ? url : url.replace(/^data:[^;]*;/, 'data:attachment/file;')
|
url = isChromeIOS ? url : url.replace(/^data:[^;]*;/, 'data:attachment/file;')
|
||||||
if (popup) popup.location.href = url
|
if (popup) popup.location.href = url
|
||||||
else location = url
|
else location = url
|
||||||
popup = null // reverse-tabnabbing #460
|
popup = null // reverse-tabnabbing #460
|
||||||
}
|
}
|
||||||
reader.readAsDataURL(blob)
|
reader.readAsDataURL(blob)
|
||||||
} else {
|
} else {
|
||||||
var URL = _global.URL || _global.webkitURL
|
var URL = _global.URL || _global.webkitURL
|
||||||
var url = URL.createObjectURL(blob)
|
var url = URL.createObjectURL(blob)
|
||||||
if (popup) popup.location = url
|
if (popup) popup.location = url
|
||||||
else location.href = url
|
else location.href = url
|
||||||
popup = null // reverse-tabnabbing #460
|
popup = null // reverse-tabnabbing #460
|
||||||
setTimeout(function () { URL.revokeObjectURL(url) }, 4E4) // 40s
|
setTimeout(function () { URL.revokeObjectURL(url) }, 4E4) // 40s
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
_global.saveAs = saveAs.saveAs = saveAs
|
_global.saveAs = saveAs.saveAs = saveAs
|
||||||
|
|
||||||
if (typeof module !== 'undefined') {
|
if (typeof module !== 'undefined') {
|
||||||
module.exports = saveAs;
|
module.exports = saveAs;
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/** vim: et:ts=4:sw=4:sts=4
|
/** vim: et:ts=4:sw=4:sts=4
|
||||||
* @license RequireJS 2.3.3 Copyright jQuery Foundation and other contributors.
|
* @license RequireJS 2.3.3 Copyright jQuery Foundation and other contributors.
|
||||||
* Released under MIT license, https://github.com/requirejs/requirejs/blob/master/LICENSE
|
* Released under MIT license, https://github.com/requirejs/requirejs/blob/master/LICENSE
|
||||||
*/
|
*/
|
||||||
@ -26,7 +26,7 @@ var requirejs, require, define;
|
|||||||
// then 'complete'. The UA check is unfortunate, but not sure how
|
// then 'complete'. The UA check is unfortunate, but not sure how
|
||||||
//to feature test w/o causing perf issues.
|
//to feature test w/o causing perf issues.
|
||||||
readyRegExp = isBrowser && navigator.platform === 'PLAYSTATION 3' ?
|
readyRegExp = isBrowser && navigator.platform === 'PLAYSTATION 3' ?
|
||||||
/^complete$/ : /^(complete|loaded)$/,
|
/^complete$/ : /^(complete|loaded)$/,
|
||||||
defContextName = '_',
|
defContextName = '_',
|
||||||
//Oh the tragedy, detecting opera. See the usage of isOpera for reason.
|
//Oh the tragedy, detecting opera. See the usage of isOpera for reason.
|
||||||
isOpera = typeof opera !== 'undefined' && opera.toString() === '[object Opera]',
|
isOpera = typeof opera !== 'undefined' && opera.toString() === '[object Opera]',
|
||||||
@ -359,7 +359,7 @@ var requirejs, require, define;
|
|||||||
if (isBrowser) {
|
if (isBrowser) {
|
||||||
each(scripts(), function (scriptNode) {
|
each(scripts(), function (scriptNode) {
|
||||||
if (scriptNode.getAttribute('data-requiremodule') === name &&
|
if (scriptNode.getAttribute('data-requiremodule') === name &&
|
||||||
scriptNode.getAttribute('data-requirecontext') === context.contextName) {
|
scriptNode.getAttribute('data-requirecontext') === context.contextName) {
|
||||||
scriptNode.parentNode.removeChild(scriptNode);
|
scriptNode.parentNode.removeChild(scriptNode);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -456,8 +456,8 @@ var requirejs, require, define;
|
|||||||
// loading of a loader plugin. But for now, fixes the
|
// loading of a loader plugin. But for now, fixes the
|
||||||
// common uses. Details in #1131
|
// common uses. Details in #1131
|
||||||
normalizedName = name.indexOf('!') === -1 ?
|
normalizedName = name.indexOf('!') === -1 ?
|
||||||
normalize(name, parentName, applyMap) :
|
normalize(name, parentName, applyMap) :
|
||||||
name;
|
name;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
//A regular module.
|
//A regular module.
|
||||||
@ -479,8 +479,8 @@ var requirejs, require, define;
|
|||||||
//normalization, stamp it with a unique ID so two matching relative
|
//normalization, stamp it with a unique ID so two matching relative
|
||||||
//ids that may conflict can be separate.
|
//ids that may conflict can be separate.
|
||||||
suffix = prefix && !pluginModule && !isNormalized ?
|
suffix = prefix && !pluginModule && !isNormalized ?
|
||||||
'_unnormalized' + (unnormalizedCounter += 1) :
|
'_unnormalized' + (unnormalizedCounter += 1) :
|
||||||
'';
|
'';
|
||||||
|
|
||||||
return {
|
return {
|
||||||
prefix: prefix,
|
prefix: prefix,
|
||||||
@ -491,8 +491,8 @@ var requirejs, require, define;
|
|||||||
originalName: originalName,
|
originalName: originalName,
|
||||||
isDefine: isDefine,
|
isDefine: isDefine,
|
||||||
id: (prefix ?
|
id: (prefix ?
|
||||||
prefix + '!' + normalizedName :
|
prefix + '!' + normalizedName :
|
||||||
normalizedName) + suffix
|
normalizedName) + suffix
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -512,7 +512,7 @@ var requirejs, require, define;
|
|||||||
mod = getOwn(registry, id);
|
mod = getOwn(registry, id);
|
||||||
|
|
||||||
if (hasProp(defined, id) &&
|
if (hasProp(defined, id) &&
|
||||||
(!mod || mod.defineEmitComplete)) {
|
(!mod || mod.defineEmitComplete)) {
|
||||||
if (name === 'defined') {
|
if (name === 'defined') {
|
||||||
fn(defined[id]);
|
fn(defined[id]);
|
||||||
}
|
}
|
||||||
@ -558,7 +558,7 @@ var requirejs, require, define;
|
|||||||
function takeGlobalQueue() {
|
function takeGlobalQueue() {
|
||||||
//Push all the globalDefQueue items into the context's defQueue
|
//Push all the globalDefQueue items into the context's defQueue
|
||||||
if (globalDefQueue.length) {
|
if (globalDefQueue.length) {
|
||||||
each(globalDefQueue, function (queueItem) {
|
each(globalDefQueue, function(queueItem) {
|
||||||
var id = queueItem[0];
|
var id = queueItem[0];
|
||||||
if (typeof id === 'string') {
|
if (typeof id === 'string') {
|
||||||
context.defQueueMap[id] = true;
|
context.defQueueMap[id] = true;
|
||||||
@ -974,8 +974,8 @@ var requirejs, require, define;
|
|||||||
//prefix and name should already be normalized, no need
|
//prefix and name should already be normalized, no need
|
||||||
//for applying map config again either.
|
//for applying map config again either.
|
||||||
normalizedMap = makeModuleMap(map.prefix + '!' + name,
|
normalizedMap = makeModuleMap(map.prefix + '!' + name,
|
||||||
this.map.parentMap,
|
this.map.parentMap,
|
||||||
true);
|
true);
|
||||||
on(normalizedMap,
|
on(normalizedMap,
|
||||||
'defined', bind(this, function (value) {
|
'defined', bind(this, function (value) {
|
||||||
this.map.normalizedMap = normalizedMap;
|
this.map.normalizedMap = normalizedMap;
|
||||||
@ -1067,10 +1067,10 @@ var requirejs, require, define;
|
|||||||
req.exec(text);
|
req.exec(text);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return onError(makeError('fromtexteval',
|
return onError(makeError('fromtexteval',
|
||||||
'fromText eval for ' + id +
|
'fromText eval for ' + id +
|
||||||
' failed: ' + e,
|
' failed: ' + e,
|
||||||
e,
|
e,
|
||||||
[id]));
|
[id]));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hasInteractive) {
|
if (hasInteractive) {
|
||||||
@ -1117,9 +1117,9 @@ var requirejs, require, define;
|
|||||||
//Dependency needs to be converted to a depMap
|
//Dependency needs to be converted to a depMap
|
||||||
//and wired up to this module.
|
//and wired up to this module.
|
||||||
depMap = makeModuleMap(depMap,
|
depMap = makeModuleMap(depMap,
|
||||||
(this.map.isDefine ? this.map : this.map.parentMap),
|
(this.map.isDefine ? this.map : this.map.parentMap),
|
||||||
false,
|
false,
|
||||||
!this.skipMap);
|
!this.skipMap);
|
||||||
this.depMaps[i] = depMap;
|
this.depMaps[i] = depMap;
|
||||||
|
|
||||||
handler = getOwn(handlers, depMap.id);
|
handler = getOwn(handlers, depMap.id);
|
||||||
@ -1145,7 +1145,7 @@ var requirejs, require, define;
|
|||||||
// No direct errback on this module, but something
|
// No direct errback on this module, but something
|
||||||
// else is listening for errors, so be sure to
|
// else is listening for errors, so be sure to
|
||||||
// propagate the error correctly.
|
// propagate the error correctly.
|
||||||
on(depMap, 'error', bind(this, function (err) {
|
on(depMap, 'error', bind(this, function(err) {
|
||||||
this.emit('error', err);
|
this.emit('error', err);
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
@ -1290,7 +1290,7 @@ var requirejs, require, define;
|
|||||||
// Convert old style urlArgs string to a function.
|
// Convert old style urlArgs string to a function.
|
||||||
if (typeof cfg.urlArgs === 'string') {
|
if (typeof cfg.urlArgs === 'string') {
|
||||||
var urlArgs = cfg.urlArgs;
|
var urlArgs = cfg.urlArgs;
|
||||||
cfg.urlArgs = function (id, url) {
|
cfg.urlArgs = function(id, url) {
|
||||||
return (url.indexOf('?') === -1 ? '?' : '&') + urlArgs;
|
return (url.indexOf('?') === -1 ? '?' : '&') + urlArgs;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -1349,7 +1349,7 @@ var requirejs, require, define;
|
|||||||
each(cfg.packages, function (pkgObj) {
|
each(cfg.packages, function (pkgObj) {
|
||||||
var location, name;
|
var location, name;
|
||||||
|
|
||||||
pkgObj = typeof pkgObj === 'string' ? { name: pkgObj } : pkgObj;
|
pkgObj = typeof pkgObj === 'string' ? {name: pkgObj} : pkgObj;
|
||||||
|
|
||||||
name = pkgObj.name;
|
name = pkgObj.name;
|
||||||
location = pkgObj.location;
|
location = pkgObj.location;
|
||||||
@ -1363,8 +1363,8 @@ var requirejs, require, define;
|
|||||||
//envs have different conventions: some use a module name,
|
//envs have different conventions: some use a module name,
|
||||||
//some use a file name.
|
//some use a file name.
|
||||||
config.pkgs[name] = pkgObj.name + '/' + (pkgObj.main || 'main')
|
config.pkgs[name] = pkgObj.name + '/' + (pkgObj.main || 'main')
|
||||||
.replace(currDirRegExp, '')
|
.replace(currDirRegExp, '')
|
||||||
.replace(jsSuffixRegExp, '');
|
.replace(jsSuffixRegExp, '');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1434,10 +1434,10 @@ var requirejs, require, define;
|
|||||||
|
|
||||||
if (!hasProp(defined, id)) {
|
if (!hasProp(defined, id)) {
|
||||||
return onError(makeError('notloaded', 'Module name "' +
|
return onError(makeError('notloaded', 'Module name "' +
|
||||||
id +
|
id +
|
||||||
'" has not been loaded yet for context: ' +
|
'" has not been loaded yet for context: ' +
|
||||||
contextName +
|
contextName +
|
||||||
(relMap ? '' : '. Use require([])')));
|
(relMap ? '' : '. Use require([])')));
|
||||||
}
|
}
|
||||||
return defined[id];
|
return defined[id];
|
||||||
}
|
}
|
||||||
@ -1489,7 +1489,7 @@ var requirejs, require, define;
|
|||||||
}
|
}
|
||||||
|
|
||||||
return context.nameToUrl(normalize(moduleNamePlusExt,
|
return context.nameToUrl(normalize(moduleNamePlusExt,
|
||||||
relMap && relMap.id, true), ext, true);
|
relMap && relMap.id, true), ext, true);
|
||||||
},
|
},
|
||||||
|
|
||||||
defined: function (id) {
|
defined: function (id) {
|
||||||
@ -1522,7 +1522,7 @@ var requirejs, require, define;
|
|||||||
//Clean queued defines too. Go backwards
|
//Clean queued defines too. Go backwards
|
||||||
//in array so that the splices do not
|
//in array so that the splices do not
|
||||||
//mess up the iteration.
|
//mess up the iteration.
|
||||||
eachReverse(defQueue, function (args, i) {
|
eachReverse(defQueue, function(args, i) {
|
||||||
if (args[0] === id) {
|
if (args[0] === id) {
|
||||||
defQueue.splice(i, 1);
|
defQueue.splice(i, 1);
|
||||||
}
|
}
|
||||||
@ -1601,9 +1601,9 @@ var requirejs, require, define;
|
|||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
return onError(makeError('nodefine',
|
return onError(makeError('nodefine',
|
||||||
'No define call for ' + moduleName,
|
'No define call for ' + moduleName,
|
||||||
null,
|
null,
|
||||||
[moduleName]));
|
[moduleName]));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
//A script that does not call define(), so just simulate
|
//A script that does not call define(), so just simulate
|
||||||
@ -1676,7 +1676,7 @@ var requirejs, require, define;
|
|||||||
}
|
}
|
||||||
|
|
||||||
return config.urlArgs && !/^blob\:/.test(url) ?
|
return config.urlArgs && !/^blob\:/.test(url) ?
|
||||||
url + config.urlArgs(moduleName, url) : url;
|
url + config.urlArgs(moduleName, url) : url;
|
||||||
},
|
},
|
||||||
|
|
||||||
//Delegates to req.load. Broken out as a separate function to
|
//Delegates to req.load. Broken out as a separate function to
|
||||||
@ -1707,7 +1707,7 @@ var requirejs, require, define;
|
|||||||
//all old browsers will be supported, but this one was easy enough
|
//all old browsers will be supported, but this one was easy enough
|
||||||
//to support and still makes sense.
|
//to support and still makes sense.
|
||||||
if (evt.type === 'load' ||
|
if (evt.type === 'load' ||
|
||||||
(readyRegExp.test((evt.currentTarget || evt.srcElement).readyState))) {
|
(readyRegExp.test((evt.currentTarget || evt.srcElement).readyState))) {
|
||||||
//Reset interactive script so a script node is not held onto for
|
//Reset interactive script so a script node is not held onto for
|
||||||
//to long.
|
//to long.
|
||||||
interactiveScript = null;
|
interactiveScript = null;
|
||||||
@ -1725,9 +1725,9 @@ var requirejs, require, define;
|
|||||||
var data = getScriptData(evt);
|
var data = getScriptData(evt);
|
||||||
if (!hasPathFallback(data.id)) {
|
if (!hasPathFallback(data.id)) {
|
||||||
var parents = [];
|
var parents = [];
|
||||||
eachProp(registry, function (value, key) {
|
eachProp(registry, function(value, key) {
|
||||||
if (key.indexOf('_@r') !== 0) {
|
if (key.indexOf('_@r') !== 0) {
|
||||||
each(value.depMaps, function (depMap) {
|
each(value.depMaps, function(depMap) {
|
||||||
if (depMap.id === data.id) {
|
if (depMap.id === data.id) {
|
||||||
parents.push(key);
|
parents.push(key);
|
||||||
return true;
|
return true;
|
||||||
@ -1736,9 +1736,9 @@ var requirejs, require, define;
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
return onError(makeError('scripterror', 'Script error for "' + data.id +
|
return onError(makeError('scripterror', 'Script error for "' + data.id +
|
||||||
(parents.length ?
|
(parents.length ?
|
||||||
'", needed by: ' + parents.join(', ') :
|
'", needed by: ' + parents.join(', ') :
|
||||||
'"'), evt, [data.id]));
|
'"'), evt, [data.id]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -1874,8 +1874,8 @@ var requirejs, require, define;
|
|||||||
*/
|
*/
|
||||||
req.createNode = function (config, moduleName, url) {
|
req.createNode = function (config, moduleName, url) {
|
||||||
var node = config.xhtml ?
|
var node = config.xhtml ?
|
||||||
document.createElementNS('http://www.w3.org/1999/xhtml', 'html:script') :
|
document.createElementNS('http://www.w3.org/1999/xhtml', 'html:script') :
|
||||||
document.createElement('script');
|
document.createElement('script');
|
||||||
node.type = config.scriptType || 'text/javascript';
|
node.type = config.scriptType || 'text/javascript';
|
||||||
node.charset = 'utf-8';
|
node.charset = 'utf-8';
|
||||||
node.async = true;
|
node.async = true;
|
||||||
@ -1910,15 +1910,15 @@ var requirejs, require, define;
|
|||||||
//UNFORTUNATELY Opera implements attachEvent but does not follow the script
|
//UNFORTUNATELY Opera implements attachEvent but does not follow the script
|
||||||
//script execution mode.
|
//script execution mode.
|
||||||
if (node.attachEvent &&
|
if (node.attachEvent &&
|
||||||
//Check if node.attachEvent is artificially added by custom script or
|
//Check if node.attachEvent is artificially added by custom script or
|
||||||
//natively supported by browser
|
//natively supported by browser
|
||||||
//read https://github.com/requirejs/requirejs/issues/187
|
//read https://github.com/requirejs/requirejs/issues/187
|
||||||
//if we can NOT find [native code] then it must NOT natively supported.
|
//if we can NOT find [native code] then it must NOT natively supported.
|
||||||
//in IE8, node.attachEvent does not have toString()
|
//in IE8, node.attachEvent does not have toString()
|
||||||
//Note the test for "[native code" with no closing brace, see:
|
//Note the test for "[native code" with no closing brace, see:
|
||||||
//https://github.com/requirejs/requirejs/issues/273
|
//https://github.com/requirejs/requirejs/issues/273
|
||||||
!(node.attachEvent.toString && node.attachEvent.toString().indexOf('[native code') < 0) &&
|
!(node.attachEvent.toString && node.attachEvent.toString().indexOf('[native code') < 0) &&
|
||||||
!isOpera) {
|
!isOpera) {
|
||||||
//Probably IE. IE (at least 6-8) do not fire
|
//Probably IE. IE (at least 6-8) do not fire
|
||||||
//script onload right after executing the script, so
|
//script onload right after executing the script, so
|
||||||
//we cannot tie the anonymous define call to a name.
|
//we cannot tie the anonymous define call to a name.
|
||||||
@ -1975,17 +1975,17 @@ var requirejs, require, define;
|
|||||||
// Post a task to the event loop to work around a bug in WebKit
|
// Post a task to the event loop to work around a bug in WebKit
|
||||||
// where the worker gets garbage-collected after calling
|
// where the worker gets garbage-collected after calling
|
||||||
// importScripts(): https://webkit.org/b/153317
|
// importScripts(): https://webkit.org/b/153317
|
||||||
setTimeout(function () { }, 0);
|
setTimeout(function() {}, 0);
|
||||||
importScripts(url);
|
importScripts(url);
|
||||||
|
|
||||||
//Account for anonymous modules
|
//Account for anonymous modules
|
||||||
context.completeLoad(moduleName);
|
context.completeLoad(moduleName);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
context.onError(makeError('importscripts',
|
context.onError(makeError('importscripts',
|
||||||
'importScripts failed for ' +
|
'importScripts failed for ' +
|
||||||
moduleName + ' at ' + url,
|
moduleName + ' at ' + url,
|
||||||
e,
|
e,
|
||||||
[moduleName]));
|
[moduleName]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -2029,7 +2029,7 @@ var requirejs, require, define;
|
|||||||
//baseUrl.
|
//baseUrl.
|
||||||
src = mainScript.split('/');
|
src = mainScript.split('/');
|
||||||
mainScript = src.pop();
|
mainScript = src.pop();
|
||||||
subPath = src.length ? src.join('/') + '/' : './';
|
subPath = src.length ? src.join('/') + '/' : './';
|
||||||
|
|
||||||
cfg.baseUrl = subPath;
|
cfg.baseUrl = subPath;
|
||||||
}
|
}
|
||||||
|
@ -1,69 +1,70 @@
|
|||||||
var require = typeof require === 'undefined' ? {} : require;
|
var require = typeof require === 'undefined' ? {} : require;
|
||||||
|
|
||||||
require.urlArgs = require.urlArgs || 'version=1496767636459';
|
require.urlArgs=require.urlArgs || 'version=1496767636459';
|
||||||
require.waitSeconds = 0;
|
require.waitSeconds=0;
|
||||||
require.config = require.config || {};
|
require.config=require.config || {};
|
||||||
require.config.ord = require.config.ord || {};
|
require.config.ord=require.config.ord || {};
|
||||||
require.config.ord.useLocalWbRc = false;
|
require.config.ord.useLocalWbRc=false;
|
||||||
require.config.baja = require.config.baja || {};
|
require.config.baja=require.config.baja || {};
|
||||||
require.config.baja.webdev = false;
|
require.config.baja.webdev=false;
|
||||||
require.config.baja.offline = false;
|
require.config.baja.offline=false;
|
||||||
require.config.lex = require.config.lex || {};
|
require.config.lex=require.config.lex || {};
|
||||||
require.config.lex.webdev = false;
|
require.config.lex.webdev=false;
|
||||||
require.hbs = require.hbs || {};
|
require.hbs=require.hbs || {};
|
||||||
require.hbs.i18n = require.hbs.i18n === undefined ? false : require.hbs.i18n;
|
require.hbs.i18n=require.hbs.i18n===undefined?false:require.hbs.i18n;
|
||||||
require.hbs.helpers = require.hbs.helpers === undefined ? false : require.hbs.helpers;
|
require.hbs.helpers=require.hbs.helpers===undefined?false:require.hbs.helpers;
|
||||||
require.hbs.fetchText = function (uri, callback) {
|
require.hbs.fetchText = function (uri, callback) {
|
||||||
function unmodularize(href) {
|
function unmodularize(href) {
|
||||||
var res;
|
var res;
|
||||||
if (href) {
|
if (href) {
|
||||||
res = /^module:\/\/(.+)$/.exec(href);
|
res = /^module:\/\/(.+)$/.exec(href);
|
||||||
if (res && res[1]) {
|
if (res && res[1]) {
|
||||||
href = '/module/' + res[1];
|
href = '/module/' + res[1];
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return href;
|
|
||||||
}
|
}
|
||||||
|
return href;
|
||||||
|
}
|
||||||
|
|
||||||
require(['baja!', 'jquery'], function (baja, $) {
|
require(['baja!', 'jquery'], function (baja, $) {
|
||||||
if (baja.isOffline()) {
|
if (baja.isOffline()) {
|
||||||
uri = /([^?]*)\??.*/.exec(uri)[1];
|
uri = /([^?]*)\??.*/.exec(uri)[1];
|
||||||
uri = uri.replace('https://workbench/module/', 'module://');
|
uri = uri.replace('https://workbench/module/', 'module://');
|
||||||
baja.rpc('type:web:FileRpc', 'readTextFile', uri)
|
baja.rpc('type:web:FileRpc', 'readTextFile', uri)
|
||||||
.then(function (text) {
|
.then(function (text) {
|
||||||
callback(text, uri);
|
callback(text, uri);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$.ajax(unmodularize(uri)).then(function (text) {
|
$.ajax(unmodularize(uri)).then(function (text) {
|
||||||
callback(text, uri);
|
callback(text, uri);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
require.config['nmodule/js/rc/lex/lex'] = { storageId: '1496767636459', lang: 'en-US' };
|
require.config['nmodule/js/rc/lex/lex']={storageId:'1496767636459',lang:'en-US'};
|
||||||
require.paths = require.paths || {};
|
require.paths=require.paths || {};
|
||||||
require.paths.nmodule = require.paths.nmodule || '/module';
|
//require.paths.jquery=require.paths.jquery || '/module/js/rc/jquery/jquery-3.1.1.min'; //add
|
||||||
require.paths.Promise = require.paths.Promise || '/module/js/rc/bluebird/bluebird.min';
|
require.paths.nmodule=require.paths.nmodule || '/module';
|
||||||
require.paths.bajaScript = require.paths.bajaScript || '/module/bajaScript/rc';
|
require.paths.Promise=require.paths.Promise || '/module/js/rc/bluebird/bluebird.min';
|
||||||
require.paths.bajaux = require.paths.bajaux || '/module/bajaux/rc';
|
require.paths.bajaScript=require.paths.bajaScript || '/module/bajaScript/rc';
|
||||||
require.paths.jquery = require.paths.jquery || '/module/js/rc/jquery/jquery-3.1.1.min';
|
require.paths.bajaux=require.paths.bajaux || '/module/bajaux/rc';
|
||||||
|
//require.paths.jquery=require.paths.jquery || '/module/js/rc/jquery/jquery-3.1.1.min';
|
||||||
//require.paths.jqueryUI=require.paths.jqueryUI || 'file:^html/js/jquery-ui.min';
|
//require.paths.jqueryUI=require.paths.jqueryUI || 'file:^html/js/jquery-ui.min';
|
||||||
require.paths.dialogs = require.paths.dialogs || '/module/js/rc/dialogs/dialogs.built.min';
|
require.paths.dialogs=require.paths.dialogs || '/module/js/rc/dialogs/dialogs.built.min';
|
||||||
require.paths.ord = require.paths.ord || '/module/js/com/tridium/js/require/ord';
|
require.paths.ord=require.paths.ord || '/module/js/com/tridium/js/require/ord';
|
||||||
require.paths.lex = require.paths.lex || '/module/js/rc/lex/lexplugin';
|
require.paths.lex=require.paths.lex || '/module/js/rc/lex/lexplugin';
|
||||||
require.paths.css = require.paths.css || '/module/js/com/tridium/js/ext/require/css';
|
require.paths.css=require.paths.css || '/module/js/com/tridium/js/ext/require/css';
|
||||||
require.paths.baja = require.paths.baja || '/module/bajaScript/rc/plugin/baja';
|
require.paths.baja=require.paths.baja || '/module/bajaScript/rc/plugin/baja';
|
||||||
require.paths.obix = require.paths.obix || '/module/obixjs/rc/obix.built.min';
|
require.paths.obix=require.paths.obix || '/module/obixjs/rc/obix.built.min';
|
||||||
require.paths.Handlebars = require.paths.Handlebars || '/module/js/rc/handlebars/handlebars.min-v2.0.0';
|
require.paths.Handlebars=require.paths.Handlebars || '/module/js/rc/handlebars/handlebars.min-v2.0.0';
|
||||||
require.paths.underscore = require.paths.underscore || '/module/js/rc/underscore/underscore.min';
|
require.paths.underscore=require.paths.underscore || '/module/js/rc/underscore/underscore.min';
|
||||||
require.paths.hbs = require.paths.hbs || '/module/js/rc/require-handlebars-plugin/hbs.built.min';
|
require.paths.hbs=require.paths.hbs || '/module/js/rc/require-handlebars-plugin/hbs.built.min';
|
||||||
require.paths.moment = require.paths.moment || '/module/js/rc/moment/moment.min';
|
require.paths.moment=require.paths.moment || '/module/js/rc/moment/moment.min';
|
||||||
require.paths.d3 = require.paths.d3 || '/module/js/rc/d3/d3.min';
|
require.paths.d3=require.paths.d3 || '/module/js/rc/d3/d3.min';
|
||||||
require.paths.hx = require.paths.hx || '/module/hx/javax/baja/hx/hx';
|
require.paths.hx=require.paths.hx || '/module/hx/javax/baja/hx/hx';
|
||||||
require.paths.jqueryContextMenu = require.paths.jqueryContextMenu || '/module/js/rc/jquery/contextMenu/jquery.contextMenu';
|
require.paths.jqueryContextMenu=require.paths.jqueryContextMenu || '/module/js/rc/jquery/contextMenu/jquery.contextMenu';
|
||||||
require.paths.ace = require.paths.ace || '/module/js/rc/ace';
|
require.paths.ace=require.paths.ace || '/module/js/rc/ace';
|
||||||
require.shim = require.shim || {};
|
require.shim=require.shim || {};
|
||||||
require.shim.d3 = require.shim.d3 || {};
|
require.shim.d3=require.shim.d3 || {};
|
||||||
require.shim.d3.exports = require.shim.d3.exports || 'd3';
|
require.shim.d3.exports=require.shim.d3.exports || 'd3';
|
||||||
require.shim.jqueryContextMenu = require.shim.jqueryContextMenu || { deps: ['jquery'], exports: 'jQuery' };
|
//require.shim.jqueryContextMenu=require.shim.jqueryContextMenu || {deps:['jquery'],exports:'jQuery'};
|
@ -1,10 +1,10 @@
|
|||||||
require.config({
|
require.config({
|
||||||
baseUrl: 'js',
|
baseUrl: 'js',
|
||||||
|
|
||||||
"paths": {
|
"paths": {
|
||||||
"jquery-ui": "//cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui",
|
"jquery-ui": "//cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui",
|
||||||
"jquery-ui-min": "//cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min",
|
"jquery-ui-min": "//cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min",
|
||||||
"d3": "https://d3js.org/d3.v4.min"
|
"d3" : "https://d3js.org/d3.v4.min"
|
||||||
},
|
},
|
||||||
|
|
||||||
shim: {
|
shim: {
|
||||||
|
@ -6,15 +6,6 @@ var varApiUrl = "/api/"; //API路徑
|
|||||||
var varPathImg = "/Upload/Images/";
|
var varPathImg = "/Upload/Images/";
|
||||||
var varPathFile = "/Upload/Files/";
|
var varPathFile = "/Upload/Files/";
|
||||||
var statusArr = { 1: "啟用", 0: "未啟用", 9: "刪除" };
|
var statusArr = { 1: "啟用", 0: "未啟用", 9: "刪除" };
|
||||||
var common = {
|
|
||||||
AddSuc:"新增成功",
|
|
||||||
EditSuc:"編輯成功",
|
|
||||||
DelSuc:"刪除成功",
|
|
||||||
AddErr:"新增失敗,",
|
|
||||||
EditErr:"編輯失敗,",
|
|
||||||
DelErr: "刪除失敗,",
|
|
||||||
SysErr: "系統內部發生錯誤,請聯繫系統管理員"
|
|
||||||
}
|
|
||||||
var objSendData = { Data: null };
|
var objSendData = { Data: null };
|
||||||
|
|
||||||
//重新轉址 for Niagara4
|
//重新轉址 for Niagara4
|
||||||
|
10872
Frontend/js/jquery.js
vendored
Normal file
10872
Frontend/js/jquery.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
2
Frontend/js/jquery.keyframes.min.js
vendored
2
Frontend/js/jquery.keyframes.min.js
vendored
File diff suppressed because one or more lines are too long
16
Frontend/js/jquery.min.js
vendored
16
Frontend/js/jquery.min.js
vendored
File diff suppressed because one or more lines are too long
@ -1,8 +1,4 @@
|
|||||||
|
|
||||||
function addzero(num) {
|
|
||||||
return num < 10 ? '0' + num : num;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 取得異常資料 by baja
|
* 取得異常資料 by baja
|
||||||
* @param {any} startDate_millisecond
|
* @param {any} startDate_millisecond
|
||||||
@ -19,7 +15,7 @@ function getAlarmByBaja(startDate_millisecond, endDate_millisecond, isRecover, i
|
|||||||
var _bfName = "";
|
var _bfName = "";
|
||||||
var _sourceName = "";
|
var _sourceName = "";
|
||||||
var _index = 0;
|
var _index = 0;
|
||||||
var _recoverState = isRecover ? "!= null" : "= null"
|
var _recoverState = isRecover ? "!= null" : "= null";
|
||||||
var _ackState = isAck ? "= 1" : "!= 1";
|
var _ackState = isAck ? "= 1" : "!= 1";
|
||||||
|
|
||||||
require(['baja!'], function (baja) {
|
require(['baja!'], function (baja) {
|
||||||
@ -54,8 +50,6 @@ function getAlarmByBaja(startDate_millisecond, endDate_millisecond, isRecover, i
|
|||||||
function getOneDeviceAlarmTop10ByBaja(devicePath, callback) {
|
function getOneDeviceAlarmTop10ByBaja(devicePath, callback) {
|
||||||
var _result = "";
|
var _result = "";
|
||||||
var _ss = "";
|
var _ss = "";
|
||||||
var _occurrenceTime = "";
|
|
||||||
var _normalTime = "";
|
|
||||||
var _index = 0;
|
var _index = 0;
|
||||||
//{ "count":2,"data": [{ "time": "2022/11/14 15:00:00", "errId": "0001", "ackCheck": "未確認", "errReason": "燈泡故障" }, { "time": "2022/11/14 15:00:00", "errId": "0002", "ackCheck": "未確認", "errReason": "燈泡故障" }]}
|
//{ "count":2,"data": [{ "time": "2022/11/14 15:00:00", "errId": "0001", "ackCheck": "未確認", "errReason": "燈泡故障" }, { "time": "2022/11/14 15:00:00", "errId": "0002", "ackCheck": "未確認", "errReason": "燈泡故障" }]}
|
||||||
require(['baja!'], function (baja) {
|
require(['baja!'], function (baja) {
|
||||||
@ -63,29 +57,16 @@ function getOneDeviceAlarmTop10ByBaja(devicePath, callback) {
|
|||||||
.then(function (table) {
|
.then(function (table) {
|
||||||
return table.cursor({
|
return table.cursor({
|
||||||
each: function (record) {
|
each: function (record) {
|
||||||
_occurrenceTime = "";
|
|
||||||
_normalTime = "";
|
|
||||||
var _resultUuid = record.get('uuid').toString().split("-");//43dc7846-bd96-4be2-ab35-f11aec729c60
|
|
||||||
|
|
||||||
var _timestampTemp = new Date(record.get('timestamp').toString());
|
|
||||||
_occurrenceTime += _timestampTemp.getFullYear().toString() + "-" + addzero(_timestampTemp.getMonth() + 1).toString() + "-" + addzero(_timestampTemp.getDate()).toString() + " " + addzero(_timestampTemp.getHours()).toString() + ":" + addzero(_timestampTemp.getMinutes()).toString() + ":" + addzero(_timestampTemp.getSeconds()).toString();
|
|
||||||
|
|
||||||
//var _occurrenceTime = _timestamp.format("yyyy-MM-dd hh:mm:ss");//.toLocaleString();
|
|
||||||
var _normaltime = new Date(record.get('normalTime').toString());
|
|
||||||
_normalTime += _normaltime.getFullYear().toString() + "-" + addzero(_normaltime.getMonth() + 1).toString() + "-" + addzero(_normaltime.getDate()).toString() + " " + addzero(_normaltime.getHours()).toString() + ":" + addzero(_normaltime.getMinutes()).toString() + ":" + addzero(_normaltime.getSeconds()).toString();
|
|
||||||
|
|
||||||
var _msgText = record.get('alarmData').get('msgText') == 1 ? _occurrenceTime : "未確認";
|
|
||||||
|
|
||||||
if (_index == 0)
|
if (_index == 0)
|
||||||
_ss += '{"uuid":"' + _resultUuid[0] + '", "msgText":"' + _msgText + '", "ackState":"' + record.get('ackState') + '", "timestamp":"' + _occurrenceTime + '", "normalTime":"' + _normalTime + '"}';
|
_ss += '{"uuid":"' + record.get('uuid') + '", "msgText":"' + record.get('alarmData').get('msgText') + '", "ackState":"' + record.get('ackState') + '", "timestamp":"' + record.get('timestamp') + '"}';
|
||||||
else
|
else
|
||||||
_ss += ',{"uuid":"' + _resultUuid[0] + '", "msgText":"' + _msgText + '", "ackState":"' + record.get('ackState') + '", "timestamp":"' + _occurrenceTime + '", "normalTime":"' + _normalTime + '"}';
|
_ss += ',{"uuid":"' + record.get('uuid') + '", "msgText":"' + record.get('alarmData').get('msgText') + '", "ackState":"' + record.get('ackState') + '", "timestamp":"' + record.get('timestamp') + '"}';
|
||||||
_index++;
|
_index++;
|
||||||
},
|
},
|
||||||
after: function () {
|
after: function () {
|
||||||
_result += '{' + '"count": ' + _index + ', "data":[';
|
_result += '{' + '"count": ' + _index +', data:[';
|
||||||
|
|
||||||
_result += _ss + ']';
|
_result += _ss+']';
|
||||||
_result += '}';
|
_result += '}';
|
||||||
if (typeof callback === 'function') {
|
if (typeof callback === 'function') {
|
||||||
callback(_result);
|
callback(_result);
|
||||||
|
30430
Frontend/js/r.js
Normal file
30430
Frontend/js/r.js
Normal file
File diff suppressed because one or more lines are too long
@ -19,30 +19,6 @@ $.fn.outerHtml = function () {
|
|||||||
return $(this).prop("outerHTML");
|
return $(this).prop("outerHTML");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* jquery validate 初始設定 | 輸出含原元素 html
|
|
||||||
*/
|
|
||||||
$.validator.setDefaults({
|
|
||||||
onkeyup: function (element, event) {
|
|
||||||
$(element).valid();
|
|
||||||
},
|
|
||||||
//errorPlacement: function (error, element) {
|
|
||||||
// if (element.hasClass("removedTitle"))
|
|
||||||
// error.insertAfter(element.next("img"));
|
|
||||||
// else
|
|
||||||
// error.insertAfter(element);
|
|
||||||
//}
|
|
||||||
});
|
|
||||||
|
|
||||||
jQuery.validator.addMethod("phone", function (phoneNumber, element) {
|
|
||||||
phoneNumber = phoneNumber.replace(/\s+/g, "");
|
|
||||||
return phoneNumber.match(/^[0-9]{9,10}$/);
|
|
||||||
}, "請輸入正確電話號碼格式");
|
|
||||||
|
|
||||||
jQuery.validator.addMethod("dbLimit", function (value, element,param) {
|
|
||||||
return value.length > param;
|
|
||||||
}, "超出輸入限制");
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 設置 bootstrap dropdown 為下拉選單
|
* 設置 bootstrap dropdown 為下拉選單
|
||||||
* @param {any} menuEle .dropdown-menu element
|
* @param {any} menuEle .dropdown-menu element
|
||||||
@ -65,10 +41,6 @@ function setDropdownItem(menuEle) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
onEvent("click", "[e-prevent]", function (e) {
|
|
||||||
e.preventDefault();
|
|
||||||
})
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 預設設備圖像
|
* 預設設備圖像
|
||||||
* @param {any} obj
|
* @param {any} obj
|
||||||
@ -83,7 +55,6 @@ function dtAjaxResetSendData(table,sendData) {
|
|||||||
d = sendData;
|
d = sendData;
|
||||||
return JSON.stringify(d)
|
return JSON.stringify(d)
|
||||||
}
|
}
|
||||||
table.ajax.reload();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -131,6 +102,6 @@ function creSelect(id = null, cls = [], name = null, data = {}, attr = {}, text
|
|||||||
}
|
}
|
||||||
|
|
||||||
function creOption(text = null, value = null, data = {}, attr = {}, cls = [], name = null, id = null) {
|
function creOption(text = null, value = null, data = {}, attr = {}, cls = [], name = null, id = null) {
|
||||||
value != null ? attr.value = value : "";
|
attr = value != null ? attr.value = value : attr;
|
||||||
return creEle("option", text, id, name, cls, data, attr);
|
return creEle("option", text, id, name, cls, data, attr);
|
||||||
}
|
}
|
@ -95,6 +95,8 @@ $.fn.YTTooltip = function (option) {
|
|||||||
} else if (obj.direction == "top" || obj.direction == "bottom"){
|
} else if (obj.direction == "top" || obj.direction == "bottom"){
|
||||||
$(clone).css({ left: offset.left, top: top});
|
$(clone).css({ left: offset.left, top: top});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
event();
|
||||||
} else {
|
} else {
|
||||||
obj.hideTooltipEvent(tooId);
|
obj.hideTooltipEvent(tooId);
|
||||||
}
|
}
|
||||||
@ -108,6 +110,8 @@ $.fn.YTTooltip = function (option) {
|
|||||||
obj.hideTooltipEvent(tooId);
|
obj.hideTooltipEvent(tooId);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
if (obj.toggle == "hover") {
|
if (obj.toggle == "hover") {
|
||||||
@ -130,6 +134,14 @@ $.fn.YTTooltip = function (option) {
|
|||||||
//}, 100)
|
//}, 100)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function event() {
|
||||||
|
let tooId = $(obj.ele).data("yttooltipid");
|
||||||
|
$("#yt_tooltip_" + tooId).off("click", "[data-close='yttooltip']");
|
||||||
|
$("#yt_tooltip_" + tooId).on("click", "[data-close='yttooltip']", function () {
|
||||||
|
hideTooltipEvent(tooId);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
eleArr.push(obj);
|
eleArr.push(obj);
|
||||||
})
|
})
|
||||||
@ -139,6 +151,8 @@ $.fn.YTTooltip = function (option) {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function resetYTTooltip() {
|
function resetYTTooltip() {
|
||||||
$("[id^=yt_tooltip_]").remove();
|
$("[id^=yt_tooltip_]").remove();
|
||||||
}
|
}
|
10872
Frontend/lib/jquery/dist/jquery.js
vendored
Normal file
10872
Frontend/lib/jquery/dist/jquery.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
2
Frontend/lib/jquery/dist/jquery.min.js
vendored
Normal file
2
Frontend/lib/jquery/dist/jquery.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
Frontend/lib/jquery/dist/jquery.min.map
vendored
Normal file
1
Frontend/lib/jquery/dist/jquery.min.map
vendored
Normal file
File diff suppressed because one or more lines are too long
476
Frontend/lib/notifications/toastr/toastr.js
Normal file
476
Frontend/lib/notifications/toastr/toastr.js
Normal file
@ -0,0 +1,476 @@
|
|||||||
|
/*
|
||||||
|
* Toastr
|
||||||
|
* Copyright 2012-2015
|
||||||
|
* Authors: John Papa, Hans Fjällemark, and Tim Ferrell.
|
||||||
|
* All Rights Reserved.
|
||||||
|
* Use, reproduction, distribution, and modification of this code is subject to the terms and
|
||||||
|
* conditions of the MIT license, available at http://www.opensource.org/licenses/mit-license.php
|
||||||
|
*
|
||||||
|
* ARIA Support: Greta Krafsig
|
||||||
|
*
|
||||||
|
* Project: https://github.com/CodeSeven/toastr
|
||||||
|
*/
|
||||||
|
/* global define */
|
||||||
|
(function (define) {
|
||||||
|
define(['jquery'], function ($) {
|
||||||
|
return (function () {
|
||||||
|
var $container;
|
||||||
|
var listener;
|
||||||
|
var toastId = 0;
|
||||||
|
var toastType = {
|
||||||
|
error: 'error',
|
||||||
|
info: 'info',
|
||||||
|
success: 'success',
|
||||||
|
warning: 'warning'
|
||||||
|
};
|
||||||
|
|
||||||
|
var toastr = {
|
||||||
|
clear: clear,
|
||||||
|
remove: remove,
|
||||||
|
error: error,
|
||||||
|
getContainer: getContainer,
|
||||||
|
info: info,
|
||||||
|
options: {},
|
||||||
|
subscribe: subscribe,
|
||||||
|
success: success,
|
||||||
|
version: '2.1.4',
|
||||||
|
warning: warning
|
||||||
|
};
|
||||||
|
|
||||||
|
var previousToast;
|
||||||
|
|
||||||
|
return toastr;
|
||||||
|
|
||||||
|
////////////////
|
||||||
|
|
||||||
|
function error(message, title, optionsOverride) {
|
||||||
|
return notify({
|
||||||
|
type: toastType.error,
|
||||||
|
iconClass: getOptions().iconClasses.error,
|
||||||
|
message: message,
|
||||||
|
optionsOverride: optionsOverride,
|
||||||
|
title: title
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function getContainer(options, create) {
|
||||||
|
if (!options) { options = getOptions(); }
|
||||||
|
$container = $('#' + options.containerId);
|
||||||
|
if ($container.length) {
|
||||||
|
return $container;
|
||||||
|
}
|
||||||
|
if (create) {
|
||||||
|
$container = createContainer(options);
|
||||||
|
}
|
||||||
|
return $container;
|
||||||
|
}
|
||||||
|
|
||||||
|
function info(message, title, optionsOverride) {
|
||||||
|
return notify({
|
||||||
|
type: toastType.info,
|
||||||
|
iconClass: getOptions().iconClasses.info,
|
||||||
|
message: message,
|
||||||
|
optionsOverride: optionsOverride,
|
||||||
|
title: title
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function subscribe(callback) {
|
||||||
|
listener = callback;
|
||||||
|
}
|
||||||
|
|
||||||
|
function success(message, title, optionsOverride) {
|
||||||
|
return notify({
|
||||||
|
type: toastType.success,
|
||||||
|
iconClass: getOptions().iconClasses.success,
|
||||||
|
message: message,
|
||||||
|
optionsOverride: optionsOverride,
|
||||||
|
title: title
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function warning(message, title, optionsOverride) {
|
||||||
|
return notify({
|
||||||
|
type: toastType.warning,
|
||||||
|
iconClass: getOptions().iconClasses.warning,
|
||||||
|
message: message,
|
||||||
|
optionsOverride: optionsOverride,
|
||||||
|
title: title
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function clear($toastElement, clearOptions) {
|
||||||
|
var options = getOptions();
|
||||||
|
if (!$container) { getContainer(options); }
|
||||||
|
if (!clearToast($toastElement, options, clearOptions)) {
|
||||||
|
clearContainer(options);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function remove($toastElement) {
|
||||||
|
var options = getOptions();
|
||||||
|
if (!$container) { getContainer(options); }
|
||||||
|
if ($toastElement && $(':focus', $toastElement).length === 0) {
|
||||||
|
removeToast($toastElement);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ($container.children().length) {
|
||||||
|
$container.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// internal functions
|
||||||
|
|
||||||
|
function clearContainer (options) {
|
||||||
|
var toastsToClear = $container.children();
|
||||||
|
for (var i = toastsToClear.length - 1; i >= 0; i--) {
|
||||||
|
clearToast($(toastsToClear[i]), options);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function clearToast ($toastElement, options, clearOptions) {
|
||||||
|
var force = clearOptions && clearOptions.force ? clearOptions.force : false;
|
||||||
|
if ($toastElement && (force || $(':focus', $toastElement).length === 0)) {
|
||||||
|
$toastElement[options.hideMethod]({
|
||||||
|
duration: options.hideDuration,
|
||||||
|
easing: options.hideEasing,
|
||||||
|
complete: function () { removeToast($toastElement); }
|
||||||
|
});
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function createContainer(options) {
|
||||||
|
$container = $('<div/>')
|
||||||
|
.attr('id', options.containerId)
|
||||||
|
.addClass(options.positionClass);
|
||||||
|
|
||||||
|
$container.appendTo($(options.target));
|
||||||
|
return $container;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getDefaults() {
|
||||||
|
return {
|
||||||
|
tapToDismiss: true,
|
||||||
|
toastClass: 'toast',
|
||||||
|
containerId: 'toast-container',
|
||||||
|
debug: false,
|
||||||
|
|
||||||
|
showMethod: 'fadeIn', //fadeIn, slideDown, and show are built into jQuery
|
||||||
|
showDuration: 300,
|
||||||
|
showEasing: 'swing', //swing and linear are built into jQuery
|
||||||
|
onShown: undefined,
|
||||||
|
hideMethod: 'fadeOut',
|
||||||
|
hideDuration: 1000,
|
||||||
|
hideEasing: 'swing',
|
||||||
|
onHidden: undefined,
|
||||||
|
closeMethod: false,
|
||||||
|
closeDuration: false,
|
||||||
|
closeEasing: false,
|
||||||
|
closeOnHover: true,
|
||||||
|
|
||||||
|
extendedTimeOut: 1000,
|
||||||
|
iconClasses: {
|
||||||
|
error: 'toast-error',
|
||||||
|
info: 'toast-info',
|
||||||
|
success: 'toast-success',
|
||||||
|
warning: 'toast-warning'
|
||||||
|
},
|
||||||
|
iconClass: 'toast-info',
|
||||||
|
positionClass: 'toast-top-right',
|
||||||
|
timeOut: 5000, // Set timeOut and extendedTimeOut to 0 to make it sticky
|
||||||
|
titleClass: 'toast-title',
|
||||||
|
messageClass: 'toast-message',
|
||||||
|
escapeHtml: false,
|
||||||
|
target: 'body',
|
||||||
|
closeHtml: '<button type="button">×</button>',
|
||||||
|
closeClass: 'toast-close-button',
|
||||||
|
newestOnTop: true,
|
||||||
|
preventDuplicates: false,
|
||||||
|
progressBar: false,
|
||||||
|
progressClass: 'toast-progress',
|
||||||
|
rtl: false
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function publish(args) {
|
||||||
|
if (!listener) { return; }
|
||||||
|
listener(args);
|
||||||
|
}
|
||||||
|
|
||||||
|
function notify(map) {
|
||||||
|
var options = getOptions();
|
||||||
|
var iconClass = map.iconClass || options.iconClass;
|
||||||
|
|
||||||
|
if (typeof (map.optionsOverride) !== 'undefined') {
|
||||||
|
options = $.extend(options, map.optionsOverride);
|
||||||
|
iconClass = map.optionsOverride.iconClass || iconClass;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (shouldExit(options, map)) { return; }
|
||||||
|
|
||||||
|
toastId++;
|
||||||
|
|
||||||
|
$container = getContainer(options, true);
|
||||||
|
|
||||||
|
var intervalId = null;
|
||||||
|
var $toastElement = $('<div/>');
|
||||||
|
var $titleElement = $('<div/>');
|
||||||
|
var $messageElement = $('<div/>');
|
||||||
|
var $progressElement = $('<div/>');
|
||||||
|
var $closeElement = $(options.closeHtml);
|
||||||
|
var progressBar = {
|
||||||
|
intervalId: null,
|
||||||
|
hideEta: null,
|
||||||
|
maxHideTime: null
|
||||||
|
};
|
||||||
|
var response = {
|
||||||
|
toastId: toastId,
|
||||||
|
state: 'visible',
|
||||||
|
startTime: new Date(),
|
||||||
|
options: options,
|
||||||
|
map: map
|
||||||
|
};
|
||||||
|
|
||||||
|
personalizeToast();
|
||||||
|
|
||||||
|
displayToast();
|
||||||
|
|
||||||
|
handleEvents();
|
||||||
|
|
||||||
|
publish(response);
|
||||||
|
|
||||||
|
if (options.debug && console) {
|
||||||
|
console.log(response);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $toastElement;
|
||||||
|
|
||||||
|
function escapeHtml(source) {
|
||||||
|
if (source == null) {
|
||||||
|
source = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
return source
|
||||||
|
.replace(/&/g, '&')
|
||||||
|
.replace(/"/g, '"')
|
||||||
|
.replace(/'/g, ''')
|
||||||
|
.replace(/</g, '<')
|
||||||
|
.replace(/>/g, '>');
|
||||||
|
}
|
||||||
|
|
||||||
|
function personalizeToast() {
|
||||||
|
setIcon();
|
||||||
|
setTitle();
|
||||||
|
setMessage();
|
||||||
|
setCloseButton();
|
||||||
|
setProgressBar();
|
||||||
|
setRTL();
|
||||||
|
setSequence();
|
||||||
|
setAria();
|
||||||
|
}
|
||||||
|
|
||||||
|
function setAria() {
|
||||||
|
var ariaValue = '';
|
||||||
|
switch (map.iconClass) {
|
||||||
|
case 'toast-success':
|
||||||
|
case 'toast-info':
|
||||||
|
ariaValue = 'polite';
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
ariaValue = 'assertive';
|
||||||
|
}
|
||||||
|
$toastElement.attr('aria-live', ariaValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleEvents() {
|
||||||
|
if (options.closeOnHover) {
|
||||||
|
$toastElement.hover(stickAround, delayedHideToast);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!options.onclick && options.tapToDismiss) {
|
||||||
|
$toastElement.click(hideToast);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (options.closeButton && $closeElement) {
|
||||||
|
$closeElement.click(function (event) {
|
||||||
|
if (event.stopPropagation) {
|
||||||
|
event.stopPropagation();
|
||||||
|
} else if (event.cancelBubble !== undefined && event.cancelBubble !== true) {
|
||||||
|
event.cancelBubble = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (options.onCloseClick) {
|
||||||
|
options.onCloseClick(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
hideToast(true);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (options.onclick) {
|
||||||
|
$toastElement.click(function (event) {
|
||||||
|
options.onclick(event);
|
||||||
|
hideToast();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function displayToast() {
|
||||||
|
$toastElement.hide();
|
||||||
|
|
||||||
|
$toastElement[options.showMethod](
|
||||||
|
{duration: options.showDuration, easing: options.showEasing, complete: options.onShown}
|
||||||
|
);
|
||||||
|
|
||||||
|
if (options.timeOut > 0) {
|
||||||
|
intervalId = setTimeout(hideToast, options.timeOut);
|
||||||
|
progressBar.maxHideTime = parseFloat(options.timeOut);
|
||||||
|
progressBar.hideEta = new Date().getTime() + progressBar.maxHideTime;
|
||||||
|
if (options.progressBar) {
|
||||||
|
progressBar.intervalId = setInterval(updateProgress, 10);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function setIcon() {
|
||||||
|
if (map.iconClass) {
|
||||||
|
$toastElement.addClass(options.toastClass).addClass(iconClass);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function setSequence() {
|
||||||
|
if (options.newestOnTop) {
|
||||||
|
$container.prepend($toastElement);
|
||||||
|
} else {
|
||||||
|
$container.append($toastElement);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function setTitle() {
|
||||||
|
if (map.title) {
|
||||||
|
var suffix = map.title;
|
||||||
|
if (options.escapeHtml) {
|
||||||
|
suffix = escapeHtml(map.title);
|
||||||
|
}
|
||||||
|
$titleElement.append(suffix).addClass(options.titleClass);
|
||||||
|
$toastElement.append($titleElement);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function setMessage() {
|
||||||
|
if (map.message) {
|
||||||
|
var suffix = map.message;
|
||||||
|
if (options.escapeHtml) {
|
||||||
|
suffix = escapeHtml(map.message);
|
||||||
|
}
|
||||||
|
$messageElement.append(suffix).addClass(options.messageClass);
|
||||||
|
$toastElement.append($messageElement);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function setCloseButton() {
|
||||||
|
if (options.closeButton) {
|
||||||
|
$closeElement.addClass(options.closeClass).attr('role', 'button');
|
||||||
|
$toastElement.prepend($closeElement);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function setProgressBar() {
|
||||||
|
if (options.progressBar) {
|
||||||
|
$progressElement.addClass(options.progressClass);
|
||||||
|
$toastElement.prepend($progressElement);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function setRTL() {
|
||||||
|
if (options.rtl) {
|
||||||
|
$toastElement.addClass('rtl');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function shouldExit(options, map) {
|
||||||
|
if (options.preventDuplicates) {
|
||||||
|
if (map.message === previousToast) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
previousToast = map.message;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function hideToast(override) {
|
||||||
|
var method = override && options.closeMethod !== false ? options.closeMethod : options.hideMethod;
|
||||||
|
var duration = override && options.closeDuration !== false ?
|
||||||
|
options.closeDuration : options.hideDuration;
|
||||||
|
var easing = override && options.closeEasing !== false ? options.closeEasing : options.hideEasing;
|
||||||
|
if ($(':focus', $toastElement).length && !override) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
clearTimeout(progressBar.intervalId);
|
||||||
|
return $toastElement[method]({
|
||||||
|
duration: duration,
|
||||||
|
easing: easing,
|
||||||
|
complete: function () {
|
||||||
|
removeToast($toastElement);
|
||||||
|
clearTimeout(intervalId);
|
||||||
|
if (options.onHidden && response.state !== 'hidden') {
|
||||||
|
options.onHidden();
|
||||||
|
}
|
||||||
|
response.state = 'hidden';
|
||||||
|
response.endTime = new Date();
|
||||||
|
publish(response);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function delayedHideToast() {
|
||||||
|
if (options.timeOut > 0 || options.extendedTimeOut > 0) {
|
||||||
|
intervalId = setTimeout(hideToast, options.extendedTimeOut);
|
||||||
|
progressBar.maxHideTime = parseFloat(options.extendedTimeOut);
|
||||||
|
progressBar.hideEta = new Date().getTime() + progressBar.maxHideTime;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function stickAround() {
|
||||||
|
clearTimeout(intervalId);
|
||||||
|
progressBar.hideEta = 0;
|
||||||
|
$toastElement.stop(true, true)[options.showMethod](
|
||||||
|
{duration: options.showDuration, easing: options.showEasing}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateProgress() {
|
||||||
|
var percentage = ((progressBar.hideEta - (new Date().getTime())) / progressBar.maxHideTime) * 100;
|
||||||
|
$progressElement.width(percentage + '%');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function getOptions() {
|
||||||
|
return $.extend({}, getDefaults(), toastr.options);
|
||||||
|
}
|
||||||
|
|
||||||
|
function removeToast($toastElement) {
|
||||||
|
if (!$container) { $container = getContainer(); }
|
||||||
|
if ($toastElement.is(':visible')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$toastElement.remove();
|
||||||
|
$toastElement = null;
|
||||||
|
if ($container.children().length === 0) {
|
||||||
|
$container.remove();
|
||||||
|
previousToast = undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
})();
|
||||||
|
});
|
||||||
|
}(typeof define === 'function' && define.amd ? define : function (deps, factory) {
|
||||||
|
if (typeof module !== 'undefined' && module.exports) { //Node
|
||||||
|
module.exports = factory(require('jquery'));
|
||||||
|
} else {
|
||||||
|
window.toastr = factory(window.jQuery);
|
||||||
|
}
|
||||||
|
}));
|
Loading…
Reference in New Issue
Block a user