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 / magellan for Bootstrap
Created December 14, 2014 17:47
This function can make navbar become fixed-top navbar when user do scrolling and top of the navbar meets the top border of browser.
jQuery(function() {
window.magellan = function() {
obj = $('.magellan');
pos = obj.offset().top;
pos2 = obj.next().offset().top-obj.innerHeight();
$(window).scroll(function() {
if (pos < $(this).scrollTop() && !obj.hasClass('navbar-fixed-top')) return obj.addClass('navbar-fixed-top');
if (pos2 > $(this).scrollTop()) return obj.removeClass('navbar-fixed-top');
});
}
@mrofi
mrofi / master.blade.php
Last active August 29, 2015 14:12
Master Layouts for Laravel + Flat Theme Bootstrap 3
<?php
$appname = isset($appname) ? $appname : 'App Name';
$pagename = ucfirst(isset($pagename) ? $pagename : Route::currentRouteName());
$title = (isset($title) ? $title : $pagename).' | ';
?>
<!DOCTYPE html>
<html lang="en">
@mrofi
mrofi / app.blade.php
Created January 2, 2015 14:07
App layouts for Laravel View
@extends('layouts.master')
<?php
$route = Route::currentRouteName();
if (!isset($user)) $user = User::find(Session::get('user_id'));
?>
@section('bodystyle') style="padding-top: 0!important;" @stop
@section('menu')
@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">
@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.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 / 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 / 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 / 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 / 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('');