in the hope it will be of inspiration for new plugin developers as it has a lot of different samples.
The source code file is now included on the download link (see first post on this thread).
The plugin has not external dependencies, so it is easy to share here.
Please if you do any enhancement or add aditional options consider to share it here so I can update the plugin for everyone.
Code: Select all
function slTalk(texto,lang){
if('speechSynthesis' in window){
var speech = new SpeechSynthesisUtterance(texto);
if(lang==""){
speech.lang = lang;
}else{
speech.lang = 'en-US';
}
window.speechSynthesis.speak(speech);
}
}
function slSubmitForm(formulario,url){
var neoApp = angular.element(document.getElementById("ng-view")).scope();
neoApp.SubmitForm(formulario,url,'POST',neoApp.Form1_submit,neoApp.Form1_success,neoApp.Form1_fail);
}
function slCenterApp(ancho,alto){
$( "body" ).css( "width", ancho+"px");
$( "body" ).css( "height", alto+"px");
$( "body" ).css( "position", "absolute");
$( "body" ).css( "top", "0px");
$( "body" ).css( "bottom", "0px");
$( "body" ).css( "left", "0px");
$( "body" ).css( "right", "0px");
$( "body" ).css( "margin", "auto");
}
function slAppBackgroundColor(color){
$( "body" ).css( "background-color", color);
}
function slAppBackgroundImage(url){
$( "body" ).css( "background-image", "url('"+url+"')");
$( "body" ).css( "background-repeat", "no-repeat");
$( "body" ).css( "background-size", "cover");
}
function slPageRoundedCorners(page,radius){
$("#"+page).css( "border-radius", radius+"px");
}
function slPageShadow(page,horizontal,vertical,theblur,thecolor){
$("#"+page).css( "box-shadow", horizontal+"px "+vertical+"px "+theblur+"px "+thecolor);
}
function slPageSetZoom(page,thezoom){
$("#"+page).css( "transform", "scale("+thezoom+","+thezoom+")");
}
function slAppSetZoom(thezoom){
$( "html" ).css( "transform-origin","0 0");
$( "html" ).css( "transform", "scale("+thezoom+","+thezoom+")");
}
function slAppSetZoom2(thezoom){
$( "html" ).css( "transform-origin","50% 50%");
$( "html" ).css( "transform", "scale("+thezoom+","+thezoom+")");
}
function slPageSetRotation(page,angle){
$("#"+page).css( "transform", "rotate("+angle+"deg)");
}
function slScaleAppFitWidth(ancho,alto){
factor1=window.innerWidth/ancho;
slCenterAppTop(ancho,alto,factor1);
slAppSetZoom(factor1);
window.onresize = function() {
factor1=window.innerWidth/ancho;
slCenterAppTop(ancho,alto,factor1);
slAppSetZoom(factor1);
}
}
function slCenterAppTop(ancho,alto,factor){
altura=parseInt((alto*factor)/2);
$( "html" ).css( "width", ancho+"px");
$( "html" ).css( "height", alto+"px");
$( "html" ).css( "position", "absolute");
$( "html" ).css( "top", "0px");
//$( "html" ).css( "bottom", "0px");
$( "html" ).css( "left", "0px");
//$( "html" ).css( "right", "0px");
$( "html" ).css( "margin", "0px");
$( "html" ).css( "overflow-x", "hidden");
$( "html" ).css( "overflow-y", "auto");
}
function slScaleAppLetterBox(ancho,alto){
slCenterApp(ancho,alto);
aspect1=ancho/alto;
aspect2=window.innerWidth/window.innerHeight;
if(aspect1<aspect2){
factor=window.innerHeight/alto;
}else{
factor=window.innerWidth/ancho;
}
if(factor>1){
slAppSetZoom2(factor);
}else{
slAppSetZoom(factor);
}
window.onresize = function() {
aspect1=ancho/alto;
aspect2=window.innerWidth/window.innerHeight;
if(aspect1<aspect2){
factor=window.innerHeight/alto;
}else{
factor=window.innerWidth/ancho;
}
if(factor>1){
slAppSetZoom2(factor);
}else{
slAppSetZoom(factor);
}
}
}
function slScaleAppDeform(ancho,alto){
slCenterApp(ancho,alto);
factor1=window.innerWidth/ancho;
factor2=window.innerHeight/alto;
$( "html" ).css( "transform-origin","50% 50%");
$( "html" ).css( "transform", "scale("+factor1+","+factor2+")");
window.onresize = function() {
factor1=window.innerWidth/ancho;
factor2=window.innerHeight/alto;
$( "html" ).css( "transform", "scale("+factor1+","+factor2+")");
}
}
function slScaleAppOriginalSize(ancho,alto){
slCenterApp(ancho,alto);
factor1=1;
factor2=1;
$( "html" ).css( "transform-origin","50% 50%");
$( "html" ).css( "transform", "scale("+factor1+","+factor2+")");
window.onresize = function() {
factor1=1;
factor2=1;
$( "html" ).css( "transform", "scale("+factor1+","+factor2+")");
}
}
function slRequestFullScreen(){
var body = document.documentElement;
if (body.requestFullscreen) {
body.requestFullscreen();
} else if (body.webkitrequestFullscreen) {
body.webkitrequestFullscreen();
} else if (body.mozrequestFullscreen) {
body.mozrequestFullscreen();
} else if (body.msrequestFullscreen) {
body.msrequestFullscreen();
}
}
function slChangeInputType(inputObject, newType, initValue){
var oldInput = $("#"+inputObject);
var newInput = oldInput.clone();
newInput.attr("type", newType);
newInput.attr("value", initValue);
newInput.attr("id", "new"+inputObject);
newInput.insertBefore(oldInput);
oldInput.remove();
newInput.attr("id", inputObject);
}
function slInputTypeRange(inputObject, minValue, maxValue){
newType="range";
var oldInput = $("#"+inputObject);
var newInput = oldInput.clone();
newInput.attr("type", newType);
newInput.attr("min", minValue);
newInput.attr("max", maxValue);
newInput.attr("value", minValue);
newInput.attr("id", "new"+inputObject);
newInput.insertBefore(oldInput);
oldInput.remove();
newInput.attr("id", inputObject);
}
function slChangeMetaViewport(newMeta){
$('head').remove('<meta name="viewport" content="width=device-width, initial-scale=1"/>');
$('head').append(newMeta);
}
function slLoadJS(url){
$.getScript(url);
}
function slLoadCSS(url){
$('<link rel="stylesheet" type="text/css" href="'+url+'" >')
.appendTo("head");
}
function slLoadHTML(containerId,url){
$("#"+containerId).load(url);
}
function slLoadGoogleFont(fontName){
$("head").append("<link href='https://fonts.googleapis.com/css?family=" + fontName + "' rel='stylesheet' type='text/css'>");
}