Skip to content

Instantly share code, notes, and snippets.

@jhonsore
jhonsore / gist:88313d434c18bc2327dd
Created February 15, 2016 18:56
Jquery validation with select hidden
<script src="jquery.js"></script>
<script src="jquery.validate.js"></script>
<script src="jquery-ui.min.js"></script>
<link href="jquery-ui.css" rel="stylesheet">
<!-- ////////////// -->
$('#select select').selectmenu(
{
appendTo: "#select",
change: function( event, ui ) {
//http://xdsoft.net/jqplugins/datetimepicker/
initDateTimePicker({mask:true, minuteRange:5,el:$('.date_hour_picker')});
initDateTimePicker({mask:true, timepicker:false, format:'d/m/Y', el:$('.datepicker')});
function initDateTimePicker(__arg__)
{
$.datetimepicker.setLocale('pt-BR');
var defaults =
@jhonsore
jhonsore / menu.html
Last active February 18, 2016 13:47
Slider Menu opened by link (Open a deep menu according to the menu id anchor)
<div class="menu-wrapper">
<div class="menu-slider">
<div class="menu">
<ul>
<li>
<div class="menu-item"><a href="home.php" class="menu-anchor" data-menu="1">Ocorrências</a><i class="spt spt-arrow-right-menu"></i></div>
</li>
<li>
<div class="menu-item"><a href="home.php" class="menu-anchor" data-menu="2">Perdas Teóricas</a><i class="spt spt-arrow-right-menu"></i></div>
</li>
@jhonsore
jhonsore / Jquery Notification.markdown
Created February 24, 2016 14:00
Jquery Notification
@jhonsore
jhonsore / gist:8c9d6c875cf943c45929
Created March 15, 2016 14:35
PHP force download
<?php
//https://davidwalsh.name/php-force-download
// grab the requested file's name
$file_name = 'pasta/file.pdf';
// make sure it's a file before doing anything!
if(is_file($file_name)) {
/*
Do any processing you'd like here:
@jhonsore
jhonsore / gist:5a0623e06f602125febe
Last active September 12, 2016 13:32
Jquery ajax
$.ajax({
type:"POST",
beforeSend: function (request)
{
request.setRequestHeader(API_NAME,X_API_KEY);
},
url:URL,
processData: false,
dataType : "json",
data: "key=value&key=value",
@jhonsore
jhonsore / download.php
Created March 18, 2016 13:21
Force download php
<?php
if(is_file($_GET['src'])) {
$file_name = $_GET['src'];
// required for IE
if(ini_get('zlib.output_compression')) { ini_set('zlib.output_compression', 'Off'); }
// get the file mime type using the file extension
switch(strtolower(substr(strrchr($file_name, '.'), 1))) {
case 'pdf': $mime = 'application/pdf'; break;
case 'zip': $mime = 'application/zip'; break;
@jhonsore
jhonsore / Hash.php
Created March 18, 2016 13:29
EncryptHash
<?php
//namespace utils;
class Hash {
//------------------------------------------------------------------------//
var $key = "e7NjchMCEGgTpsx3mKXbVPiAqn8DLzWo_6.tvwJQ-R0OUrSak954fd2FYyuH~1lIBZ";
public function __construct(/* ... */) {
$( _form ).serialize()+'&'+$.param({new:"some value"});
@jhonsore
jhonsore / javascript.js
Created March 31, 2016 19:45
Open select by click in other element
$('.custom-select button').unbind('click').click(function(){
$(this).closest('.custom-select').find('select').openSelect();
return false;
});
(function($) {
"use strict";
$.fn.openSelect = function()
{
return this.each(function(idx,domEl) {