Comparing version 3.7.1 to 3.8.0
@@ -1491,2 +1491,2 @@ jSuites.login = (function(el, options) { | ||
return obj; | ||
}); | ||
}); |
@@ -193,10 +193,17 @@ jSuites.app = (function(el, options) { | ||
jSuites.animation.slideLeft(pages, (a < b ? 0 : 1), function() { | ||
// Animation only on mobile | ||
var rect = pages.getBoundingClientRect(); | ||
if (rect.width < 800) { | ||
jSuites.animation.slideLeft(pages, (a < b ? 0 : 1), function() { | ||
if (component.current != page) { | ||
component.current.style.display = 'none'; | ||
pageIsReady(); | ||
} | ||
}); | ||
} else { | ||
if (component.current != page) { | ||
component.current.style.display = 'none'; | ||
// Page is ready | ||
pageIsReady(); | ||
} | ||
}); | ||
} | ||
} | ||
@@ -356,78 +363,5 @@ } else { | ||
obj.actionsheet = function() { | ||
// Actionsheet container | ||
var actionsheet = el.querySelector('.actionsheet'); | ||
if (! actionsheet) { | ||
var actionsheet = document.createElement('div'); | ||
actionsheet.className = 'jactionsheet'; | ||
actionsheet.style.display = 'none'; | ||
// Actionsheet | ||
obj.actionsheet = jSuites.actionsheet(el); | ||
var actionContent = document.createElement('div'); | ||
actionContent.className = 'jactionsheet-content'; | ||
actionsheet.appendChild(actionContent); | ||
// Append actionsheet container to the application | ||
el.appendChild(actionsheet); | ||
} | ||
var component = function(options) { | ||
if (options) { | ||
obj.actionsheet.options = options; | ||
} | ||
// Reset container | ||
actionContent.innerHTML = ''; | ||
// Create new elements | ||
for (var i = 0; i < obj.actionsheet.options.length; i++) { | ||
var actionGroup = document.createElement('div'); | ||
actionGroup.className = 'jactionsheet-group'; | ||
for (var j = 0; j < obj.actionsheet.options[i].length; j++) { | ||
var v = obj.actionsheet.options[i][j]; | ||
var actionItem = document.createElement('div'); | ||
var actionInput = document.createElement('input'); | ||
actionInput.type = 'button'; | ||
actionInput.value = v.title; | ||
if (v.className) { | ||
actionInput.className = v.className; | ||
} | ||
if (v.onclick) { | ||
actionInput.event = v.onclick; | ||
actionInput.onclick = function() { | ||
this.event(obj, component, this); | ||
} | ||
} | ||
if (v.action == 'cancel') { | ||
actionInput.style.color = 'red'; | ||
} | ||
actionItem.appendChild(actionInput); | ||
actionGroup.appendChild(actionItem); | ||
} | ||
actionContent.appendChild(actionGroup); | ||
} | ||
// Show | ||
actionsheet.style.display = ''; | ||
// Animation | ||
jSuites.animation.slideBottom(actionContent, true); | ||
} | ||
component.close = function() { | ||
if (actionsheet.style.display != 'none') { | ||
// Remove any existing actionsheet | ||
jSuites.animation.slideBottom(actionContent, false, function() { | ||
actionsheet.style.display = 'none'; | ||
}); | ||
} | ||
} | ||
component.get = function() { | ||
return actionsheet; | ||
} | ||
return component; | ||
}(); | ||
/* | ||
@@ -486,2 +420,10 @@ * Parse javascript from an element | ||
// Grouped buttons | ||
if (e.target.parentNode.classList.contains('jbuttons-group')) { | ||
for (var j = 0; j < e.target.parentNode.children.length; j++) { | ||
e.target.parentNode.children[j].classList.remove('selected'); | ||
} | ||
e.target.classList.add('selected'); | ||
} | ||
// App links | ||
@@ -525,3 +467,5 @@ actionElement = jSuites.findElement(e.target, function(e) { | ||
document.addEventListener('mousedown', actionDown); | ||
document.addEventListener('mouseup', actionUp); | ||
document.addEventListener('click', function(e) { | ||
actionUp(e); | ||
}); | ||
} | ||
@@ -546,2 +490,74 @@ | ||
jSuites.actionsheet = (function(el, options) { | ||
var obj = function(options) { | ||
// Reset container | ||
actionContent.innerHTML = ''; | ||
// Create new elements | ||
for (var i = 0; i < options.length; i++) { | ||
var actionGroup = document.createElement('div'); | ||
actionGroup.className = 'jactionsheet-group'; | ||
for (var j = 0; j < options[i].length; j++) { | ||
var v = options[i][j]; | ||
var actionItem = document.createElement('div'); | ||
var actionInput = document.createElement('input'); | ||
actionInput.type = 'button'; | ||
actionInput.value = v.title; | ||
if (v.className) { | ||
actionInput.className = v.className; | ||
} | ||
if (v.onclick) { | ||
actionInput.event = v.onclick; | ||
actionInput.onclick = function() { | ||
this.event(component, this); | ||
} | ||
} | ||
if (v.action == 'cancel') { | ||
actionInput.style.color = 'red'; | ||
} | ||
actionItem.appendChild(actionInput); | ||
actionGroup.appendChild(actionItem); | ||
} | ||
actionContent.appendChild(actionGroup); | ||
} | ||
// Show | ||
actionsheet.style.display = ''; | ||
// Animation | ||
jSuites.animation.slideBottom(actionContent, true); | ||
} | ||
obj.close = function() { | ||
if (actionsheet.style.display != 'none') { | ||
// Remove any existing actionsheet | ||
jSuites.animation.slideBottom(actionContent, false, function() { | ||
actionsheet.style.display = 'none'; | ||
}); | ||
} | ||
} | ||
obj.get = function() { | ||
return actionsheet; | ||
} | ||
// Init action sheet | ||
var actionsheet = document.createElement('div'); | ||
actionsheet.className = 'jactionsheet'; | ||
actionsheet.style.display = 'none'; | ||
var actionContent = document.createElement('div'); | ||
actionContent.className = 'jactionsheet-content'; | ||
actionsheet.appendChild(actionContent); | ||
// Append actionsheet container to the application | ||
el.appendChild(actionsheet); | ||
el.actionsheet = obj; | ||
return obj; | ||
}); | ||
jSuites.dialog = (function() { | ||
@@ -798,2 +814,2 @@ var obj = {}; | ||
return obj; | ||
})(); | ||
})(); |
@@ -30,3 +30,3 @@ { | ||
"main": "dist/jsuites.js", | ||
"version": "3.7.1", | ||
"version": "3.8.0", | ||
"bugs": "https://github.com/paulhodel/jsuites/issues", | ||
@@ -33,0 +33,0 @@ "homepage": "https://github.com/paulhodel/jsuites", |
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
795056
21494