include("lib.onload"); include("lib.snap"); var Mobile = { init: function() { FastClick.attach(document.body); Mobile.snapper = new Snap({ element: $("content"), dragger: null, hyperextensible: true, touchToClose: true, touchToDrag: false, disable: "right", hyperextensible: false }); var teclasHidden = function() { $('entorno-teclas').setStyle( { visibility: "hidden" }); }; var teclasInherit = function() { $('entorno-teclas').setStyle( { visibility: "inherit" }); }; $("showLeft").on("click", function(e) { if (Mobile.snapper.state().state == "closed") { Mobile.snapper.open("left"); teclasHidden(); } else if(Mobile.snapper.state().state == "left") { Mobile.snapper.close(); teclasInherit(); } }); var showOverflowMenu = function () { $("overflow-menu").toggle(); Mobile.snapper.close(); }; $("overflow").on("click", showOverflowMenu); $("overflow-menu").on("click", showOverflowMenu); $("quickMenu").on("click", function() { Menu.menuRapido.alternar(); Mobile.snapper.close(); }); var showLeftClasses = function() { $("showLeft").addClassName("visible"); $("entorno-teclas").addClassName("hide"); teclasHidden(); }; var hideLeftClasses = function() { $("showLeft").removeClassName("visible"); $("entorno-teclas").removeClassName("hide"); teclasInherit(); }; var toggle = Function.defer.bind(function() { if (Mobile.snapper.state().info.towards == 'right') { showLeftClasses(); } else { hideLeftClasses(); } }); Mobile.snapper.on("open", showLeftClasses); Mobile.snapper.on("close", hideLeftClasses); Mobile.snapper.on("end", toggle); }, preInitMenu: function() { Mobile.snapper.close(); }, initMenu: function() { $("quickMenu").show(); Menu.menuRapido.alternar(); }, initForm: function() { // Mobile.reflowLabels(); Mobile.resizeMenu(); }, resizeMenu: function() { if(!c.formulario.store) { $$('.tecla.guardar')[0].setStyle({ display: 'none' }); } else { $$('.tecla.guardar')[0].setStyle({ display: '' }); } var menuItems = $$('#entorno-teclas .tecla'); var visibleItems = 0; menuItems.forEach(function(item) { if(item.getStyle("display") !== "none") { visibleItems++; } }); var w = 100 / visibleItems; var teclasSeparacion = function() { $('entorno-teclas').childElements('button').each(function(b) { if(b.getStyle("display") === "inline-block") { b.setStyle({ "border": "1px #D4D4D4 solid" }); } }); }; menuItems.forEach(function(item) { item.setStyle({ width: w + "%" }); }); teclasSeparacion(); }, reflowLabels: function() { $$("td::first-child>span.label").each(function(e) { var input = e.up("tr").select("input[types=text]"); if (input && input[0]) { input[0].placeholder = e.innerText; e.hide(); } e.up("tr").insert({ before: new Element("tr").insert(new Element("td", { colspan: "10" }).update(e)) }); }); $$("fieldset > legend").each(function(e) { e.addClassName("holo-divider"); }); } }; addOnLoad(Mobile.init);