123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- // Avoid `console` errors in browsers that lack a console.
- (function () {
- var method;
- var noop = function () {
- };
- var methods = [
- 'assert', 'clear', 'count', 'debug', 'dir', 'dirxml', 'error',
- 'exception', 'group', 'groupCollapsed', 'groupEnd', 'info', 'log',
- 'markTimeline', 'profile', 'profileEnd', 'table', 'time', 'timeEnd',
- 'timeline', 'timelineEnd', 'timeStamp', 'trace', 'warn'
- ];
- var length = methods.length;
- var console = (window.console = window.console || {});
- while (length--) {
- method = methods[length];
- // Only stub undefined methods.
- if (!console[method]) {
- console[method] = noop;
- }
- }
- }());
- // Place any jQuery/helper plugins in here.
- $(function () {
- $.ajaxSetup({
- headers: {
- 'X-CSRF-TOKEN': $('meta[name="_token"]').attr('content')
- }
- });
- /*
- Allows you to add data-method="METHOD to links to automatically inject a form with the method on click
- Example: <a href="{{route('customers.destroy', $customer->id)}}" data-method="delete" name="delete_item">Delete</a>
- Injects a form with that's fired on click of the link with a DELETE request.
- Good because you don't have to dirty your HTML with delete forms everywhere.
- */
- $('[data-method]').append(function () {
- return "\n" +
- "<form action='" + $(this).attr('href') + "' method='POST' name='delete_item' style='display:none'>\n" +
- " <input type='hidden' name='_method' value='" + $(this).attr('data-method') + "'>\n" +
- " <input type='hidden' name='_token' value='" + $('meta[name="_token"]').attr('content') + "'>\n" +
- "</form>\n"
- })
- .removeAttr('href')
- .attr('style', 'cursor:pointer;')
- .attr('onclick', '$(this).find("form").submit();');
- /*
- Generic are you sure dialog
- */
- $('form[name=delete_item]').submit(function () {
- return confirm("确定要删除此项?");
- });
- /*
- Bind all bootstrap tooltips
- */
- $("[data-toggle=\"tooltip\"]").tooltip();
- $("[data-toggle=\"popover\"]").popover();
- //This closes the popover when its clicked away from
- $('body').on('click', function (e) {
- $('[data-toggle="popover"]').each(function () {
- if (!$(this).is(e.target) && $(this).has(e.target).length === 0 && $('.popover').has(e.target).length === 0) {
- $(this).popover('hide');
- }
- });
- });
- // 单选框 input checked radio 初始化
- $('.wrapper-content').find("input").iCheck({
- checkboxClass: 'icheckbox_square-green',
- radioClass: 'iradio_square-green',
- increaseArea: '20%'
- });
- $('.btn-dropbox').find('input').iCheck('destroy');
- // input 单选框全选or 全取消
- $('.wrapper-content .table').find(".check-all").on('ifChecked', function (e) {
- e.preventDefault();
- $(this).parents('table').find(".icheckbox_square-green").iCheck('check');
- });
- $('.wrapper-content .table').find(".check-all").on('ifUnchecked', function (e) {
- e.preventDefault();
- $(this).parents('table').find(".icheckbox_square-green").iCheck('uncheck');
- });
- $(document).on('click.modal.data-api', '[data-toggle="modal"]', function (e) {
- var $this = $(this),
- href = $this.attr('href'),
- url = $(this).data('url');
- console.log(url);
- if (url) {
- var $target = $($this.attr('data-target') || (href && href.replace(/.*(?=#[^\s]+$)/, '')));
- console.log($target.html());
- $target.html('').load(url, function () {
- });
- }
- });
- $('.modal').on('click', '[data-toggle=form-submit]', function (e) {
- e.preventDefault();
- $($(this).data('target')).submit();
- });
- });
|