Comparing version 3.8.3 to 3.8.4
@@ -608,2 +608,80 @@ jSuites.login = (function(el, options) { | ||
jSuites.menu = (function(el, options) { | ||
var obj = {}; | ||
obj.show = function() { | ||
el.style.display = 'block'; | ||
jSuites.animation.slideLeft(el, 1); | ||
} | ||
obj.hide = function() { | ||
jSuites.animation.slideLeft(el, 0, function() { | ||
el.style.display = ''; | ||
}); | ||
} | ||
obj.load = function() { | ||
if (localStorage) { | ||
var menu = el.querySelectorAll('nav'); | ||
for (var i = 0; i < menu.length; i++) { | ||
menu[i].classList.remove('selected'); | ||
if (menu[i].getAttribute('data-id')) { | ||
var state = localStorage.getItem('jmenu-' + menu[i].getAttribute('data-id')); | ||
if (state === null || state == 1) { | ||
menu[i].classList.add('selected'); | ||
} | ||
} | ||
} | ||
var href = localStorage.getItem('jmenu-href'); | ||
if (href) { | ||
var menu = document.querySelector('.jmenu a[href="'+ href +'"]'); | ||
if (menu) { | ||
menu.classList.add('selected'); | ||
} | ||
} | ||
} | ||
} | ||
var actionDown = function(e) { | ||
if (e.target.tagName == 'H2') { | ||
if (e.target.parentNode.classList.contains('selected')) { | ||
e.target.parentNode.classList.remove('selected'); | ||
localStorage.setItem('jmenu-' + e.target.parentNode.getAttribute('data-id'), 0); | ||
} else { | ||
e.target.parentNode.classList.add('selected'); | ||
localStorage.setItem('jmenu-' + e.target.parentNode.getAttribute('data-id'), 1); | ||
} | ||
} else if (e.target.tagName == 'A') { | ||
localStorage.setItem('jmenu-href', e.target.getAttribute('href')); | ||
} | ||
} | ||
if ('ontouchstart' in document.documentElement === true) { | ||
el.addEventListener('touchstart', actionDown); | ||
} else { | ||
el.addEventListener('mousedown', actionDown); | ||
} | ||
// Add close action | ||
var i = document.createElement('i'); | ||
i.className = 'material-icons small-screen-only close'; | ||
i.innerText = 'close'; | ||
i.onclick = function() { | ||
obj.hide(); | ||
} | ||
el.appendChild(i); | ||
// Add menu class | ||
el.classList.add('jmenu'); | ||
// Load state | ||
obj.load(); | ||
// Keep reference | ||
el.menu = obj; | ||
return obj; | ||
}); | ||
/** | ||
@@ -631,2 +709,3 @@ * (c) jSuites template renderer | ||
noRecordsFound: 'No records found', | ||
containerClass: null, | ||
// Searchable | ||
@@ -644,2 +723,3 @@ search: null, | ||
onsearch: null, | ||
onclick: null, | ||
} | ||
@@ -697,3 +777,6 @@ | ||
var container = document.createElement('div'); | ||
container.className = 'jtemplate-content options'; | ||
if (obj.options.containerClass) { | ||
container.className = obj.options.containerClass; | ||
} | ||
container.classList.add ('jtemplate-content'); | ||
el.appendChild(container); | ||
@@ -909,2 +992,7 @@ | ||
// Data filtering | ||
if (typeof(obj.options.filter) == 'function') { | ||
data = obj.options.filter(data); | ||
} | ||
// Reset pagination | ||
@@ -1052,9 +1140,5 @@ obj.updatePagination(); | ||
if (typeof(obj.options.filter) == 'function') { | ||
searchResults = obj.options.filter(obj.options.data, query); | ||
} else { | ||
searchResults = obj.options.data.filter(function(item) { | ||
return test(item, query); | ||
}); | ||
} | ||
searchResults = obj.options.data.filter(function(item) { | ||
return test(item, query); | ||
}); | ||
} | ||
@@ -1091,2 +1175,8 @@ | ||
el.addEventListener('click', function(e) { | ||
if (typeof(obj.options.onclick) == 'function') { | ||
obj.options.onclick(el, obj, e); | ||
} | ||
}); | ||
el.template = obj; | ||
@@ -1093,0 +1183,0 @@ |
@@ -10,5 +10,7 @@ jSuites.app = (function(el, options) { | ||
onchangepage: null, | ||
onbeforecreatepage: null, | ||
oncreatepage: null, | ||
onloadpage: null, | ||
toolbar: null, | ||
detachHiddenPages: true | ||
} | ||
@@ -93,14 +95,29 @@ | ||
// Always hidden | ||
page.style.display = 'none'; | ||
// Keep options | ||
page.options = o ? o : {}; | ||
if (! component.current) { | ||
pages.appendChild(page); | ||
} else { | ||
pages.insertBefore(page, component.current.nextSibling); | ||
var updateDOM = function() { | ||
// Remove to avoid id conflicts | ||
if (component.current && obj.options.detachHiddenPages == true) { | ||
while (pages.children[0]) { | ||
pages.children[0].parentNode.removeChild(pages.children[0]); | ||
} | ||
} | ||
if (! component.current) { | ||
pages.appendChild(page); | ||
} else { | ||
pages.insertBefore(page, component.current.nextSibling); | ||
} | ||
} | ||
// Create page overwrite | ||
var ret = null; | ||
if (typeof(obj.options.onbeforecreatepage) == 'function') { | ||
var ret = obj.options.onbeforecreatepage(obj, page); | ||
if (ret === false) { | ||
return false; | ||
} | ||
} | ||
jSuites.ajax({ | ||
@@ -111,2 +128,5 @@ url: o.url, | ||
success: function(result) { | ||
// Update DOM | ||
updateDOM(); | ||
// Create page overwrite | ||
@@ -128,5 +148,14 @@ var ret = null; | ||
// Get javascript | ||
parseScript(page); | ||
try { | ||
parseScript(page); | ||
} catch (e) { | ||
console.log(e); | ||
} | ||
} | ||
// Navbar | ||
if (page.querySelector('.navbar')) { | ||
page.classList.add('with-navbar'); | ||
} | ||
// Global onload callback | ||
@@ -142,2 +171,5 @@ if (typeof(obj.options.onloadpage) == 'function') { | ||
// Always hidden | ||
page.style.display = 'none'; | ||
// Show page | ||
@@ -155,2 +187,12 @@ if (! page.options.closed) { | ||
var pageIsReady = function() { | ||
if (component.current) { | ||
component.current.style.display = 'none'; | ||
if (component.current && obj.options.detachHiddenPages == true) { | ||
if (component.current.parentNode) { | ||
component.current.parentNode.removeChild(component.current); | ||
} | ||
} | ||
} | ||
// New page | ||
@@ -175,7 +217,9 @@ if (typeof(obj.options.onchangepage) == 'function') { | ||
// Append page in case was detached | ||
if (! page.parentNode) { | ||
pages.appendChild(page); | ||
} | ||
if (component.current) { | ||
if (component.current != page) { | ||
// Keep scroll in the top | ||
window.scrollTo({ top: 0 }); | ||
// Show page | ||
@@ -202,6 +246,7 @@ page.style.display = ''; | ||
var rect = pages.getBoundingClientRect(); | ||
if (rect.width < 800) { | ||
window.scrollTo({ top: 0 }); | ||
jSuites.animation.slideLeft(pages, (a < b ? 0 : 1), function() { | ||
if (component.current != page) { | ||
component.current.style.display = 'none'; | ||
pageIsReady(); | ||
@@ -212,3 +257,2 @@ } | ||
if (component.current != page) { | ||
component.current.style.display = 'none'; | ||
pageIsReady(); | ||
@@ -266,6 +310,39 @@ } | ||
pages.className = 'pages'; | ||
// Append page container to the application | ||
el.appendChild(pages); | ||
} | ||
// Prefetched content | ||
if (el.innerHTML) { | ||
// Create with the prefetched content | ||
var page = document.createElement('div'); | ||
page.classList.add('page'); | ||
while (el.childNodes[0]) { | ||
page.appendChild(el.childNodes[0]); | ||
} | ||
if (el.innerHTML) { | ||
var div = document.createElement('div'); | ||
div.innerHTML = pages.innerHTML; | ||
page.appendChild(div); | ||
} | ||
// Container | ||
var route = window.location.pathname; | ||
component.container[route] = page; | ||
// Keep options | ||
page.options = {}; | ||
page.options.route = route; | ||
// Current page | ||
component.current = page; | ||
// Place the page to the right container | ||
if (! component.current) { | ||
pages.appendChild(page); | ||
} else { | ||
pages.insertBefore(page, component.current.nextSibling); | ||
} | ||
} | ||
// Append page container to the application | ||
el.appendChild(pages); | ||
return component; | ||
@@ -385,4 +462,4 @@ }(); | ||
var type = script[i].getAttribute('type'); | ||
if (! type || type == 'text/javascript') { | ||
eval(script[i].innerHTML); | ||
if (! type || type == 'text/javascript' || type == 'text/loader') { | ||
eval(script[i].text); | ||
} | ||
@@ -820,2 +897,2 @@ } | ||
return obj; | ||
})(); | ||
})(); |
@@ -7,19 +7,11 @@ { | ||
"type": "git", | ||
"url": "https://github.com/paulhodel/jsuites.git" | ||
"url": "https://github.com/jsuites/jsuites.git" | ||
}, | ||
"author": { | ||
"name": "Paul Hodel <paul.hodel@gmail.com>", | ||
"url": "https://www.linkedin.com/in/paulhodel" | ||
"name": "jSuites <contact@jsuites.net>" | ||
}, | ||
"maintainers": [ | ||
{ | ||
"name": "Paul Hodel", | ||
"email": "paul.hodel@gmail.com", | ||
"url": "http://paulhodel.com" | ||
} | ||
], | ||
"licenses": [ | ||
{ | ||
"type": "MIT", | ||
"url": "https://github.com/paulhodel/jsuites/blob/master/LICENSE" | ||
"url": "https://github.com/jsuites/jsuites/blob/master/LICENSE" | ||
} | ||
@@ -31,7 +23,7 @@ ], | ||
"main": "dist/jsuites.js", | ||
"version": "3.8.3", | ||
"bugs": "https://github.com/paulhodel/jsuites/issues", | ||
"homepage": "https://github.com/paulhodel/jsuites", | ||
"version": "3.8.4", | ||
"bugs": "https://github.com/jsuites/jsuites/issues", | ||
"homepage": "https://github.com/jsuites/jsuites", | ||
"docs": "https://bossanova.uk/jsuites", | ||
"download": "https://github.com/paulhodel/jsuites/archive/master.zip" | ||
"download": "https://github.com/jsuites/jsuites/archive/master.zip" | ||
} |
@@ -52,4 +52,4 @@  | ||
<html> | ||
<script src="https://bossanova.uk/jsuites/v2/jsuites.js"></script> | ||
<link rel="stylesheet" href="https://bossanova.uk/jsuites/v2/jsuites.css" type="text/css" /> | ||
<script src="https://bossanova.uk/jsuites/v3/jsuites.js"></script> | ||
<link rel="stylesheet" href="https://bossanova.uk/jsuites/v3/jsuites.css" type="text/css" /> | ||
@@ -121,14 +121,10 @@ <div id="dropdown1"></div> | ||
## Community | ||
- [GitHub](https://github.com/paulhodel/jsuites/issues) | ||
- [GitHub](https://github.com/jsuites/jsuites/issues) | ||
## Copyright and license | ||
jSuites is released under the [MIT license]. Copyrights belong to Paul Hodel <paul.hodel@gmail.com> | ||
jSuites is released under the [MIT license]. | ||
## Other resources | ||
## Contact | ||
contact@jsuites.net | ||
- [jExcel CE v3 Official](https://bossanova.uk/jexcel/v3) | ||
- [jExcel CE v4 Official](https://bossanova.uk/jexcel/v4) | ||
- [jExcel Pro v5 Official](https://jexcel.net/v5) | ||
- [jExcel Pro v7 Official](https://jexcel.net/v7) | ||
- [Banda Base](https://base.mus.br) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
817175
22132
129