Skip to content

Instantly share code, notes, and snippets.

View mrofi's full-sized avatar
🏠
work from home

Mokhamad Rofiudin mrofi

🏠
work from home
View GitHub Profile
@mrofi
mrofi / jQuery.textAutoGrow.js
Last active August 29, 2015 14:19
Autogrow Textarea with jQuery
// MIT Licence (MIT)
// Copyright (c) 2015 - Mokhamad Rofiudin
// inspired by Facebook Textarea
// Based on code here http://github.com/jackmoore/autosize
// The Magic Sauce : http://stackoverflow.com/a/3238543/4711810
// To Angular Go To Here https://gist.github.com/mrofi/e6a8656be9705652ff1f
(function($) {
{
"caret_extra_width": 1,
"caret_style": "phase",
"close_windows_when_empty": false,
"color_scheme": "Packages/Color Scheme - Default/Monokai.tmTheme",
"drag_text": false,
"draw_minimap_border": true,
"font_options":
[
"no_round"
@mrofi
mrofi / modal.delete.hide.js
Created January 2, 2015 14:22
Modal Delete Hidden Event
$('#modal-hapus').on('hidden.bs.modal', function() {
$(this).find('#nama-user').html('user');
$(this).find('.alert').addClass('hide');
$(this).find('.global-error').html('');
$(this).find('.icon-spinner').addClass('hide');
loadData();
})
@mrofi
mrofi / form.submit.jquery.bs3.js
Created January 2, 2015 14:21
Form Submitter JS
$('form').each(function() {
$(this).off().submit(function(e) {
e.preventDefault();
form = $(this);
url = form.attr('action');
icon = form.find('button[type=submit] > .icon');
icon.removeClass('hide');
form.find('.alert').addClass('hide');
form.find('.global-error').html('');
@mrofi
mrofi / crud.bootstrap.jquery.js
Created January 2, 2015 14:20
CRUD Bootstrap 3 + jquery + laravel JS
('#tbody-data').delegate('tr .btn-edit', 'click', function(e) {
e.preventDefault();
backToCage();
btn = $(this);
tr = btn.parents('tr');
id = tr.attr('data-id');
$('#tbody-data tr.open-edit').next().remove();
if (tr.is('.open-edit')) {
tr.removeClass('open-edit');
return;
@mrofi
mrofi / BackToCage.js
Created January 2, 2015 14:18
Back To Cage (Reset and Hide the Form)
var backToCage = function() {
e = $('#edit-container');
form = e.find('form');
form[0].reset();
form.find('.alert').addClass('hide');
form.find('.global-error').html('');
form.find('.form-group').removeClass('has-error');
form.find('.error').html('');
form.find('.uploadPreview').attr('src', noImage);
form.find('[name=photo]').val(noImage);
@mrofi
mrofi / loadData.blade.php
Created January 2, 2015 14:17
loader data for bootstrap 3 + jquery + laravel
//PHP
<script id="dataTemplate" type="text/x-jquery-tmpl">
<tr data-id="${id}">
<td>${no}.</td>
<td>${id_hero}</td>
<td>${username}</td>
<td>${nama}</td>
<td>${alamat}</td>
<td>${no_hp}</td>
@mrofi
mrofi / crud.delete.php
Created January 2, 2015 14:13
Bootstrap 3 Modal Delete (CRUD) + Laravel
<div id="modal-hapus" class="modal fade">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h4 class="modal-title">Menghapus User</h4>
</div>
<div class="modal-body">
<div class="alert alert-danger alert-dismissable text-center hide">
<i class="icon icon-exclamation-sign"></i> Gagal menyimpan. <span class="global-error"></span>
@mrofi
mrofi / crud.update.php
Created January 2, 2015 14:12
Bootstrap 3 CRUD update form + laravel
<form action="/manager/user/edit" class="form-horizontal" method="post">
<input type="hidden" name="id">
<input type="hidden" name="_method" value="put">
<div class="row">
<div class="col-md-8">
<div class="alert alert-danger alert-dismissable text-center hide">
<i class="icon icon-exclamation-sign"></i> Gagal menyimpan. <span class="global-error"></span>
</div>
<div class="alert alert-success alert-dismissable text-center hide">
<i class="icon icon-exclamation-sign"></i> Berhasil menyimpan
@mrofi
mrofi / crud.create.php
Created January 2, 2015 14:11
Bootstrap 3 CRUD Create Form
<form action="/manager/user/add" class="form-horizontal" method="post">
<div class="row">
<div class="col-md-8">
<div class="alert alert-danger alert-dismissable text-center hide">
<i class="icon icon-exclamation-sign"></i> Gagal menyimpan. <span class="global-error"></span>
</div>
<div class="alert alert-success alert-dismissable text-center hide">
<i class="icon icon-exclamation-sign"></i> Berhasil menyimpan
</div>
<div class="form-group">