123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135 |
- $.fn.editable.defaults.params = function(params) {
- params._editable = 1;
- params._method = 'PUT';
- return params;
- }
- ;
- $.fn.editable.defaults.error = function(data) {
- var msg = '';
- if (data.responseJSON.errors) {
- $.each(data.responseJSON.errors, function(k, v) {
- msg += v + "\n";
- });
- }
- return msg
- }
- ;
- toastr.options = {
- closeButton: true,
- progressBar: true,
- showMethod: 'slideDown',
- timeOut: 4000
- };
- $(document).delegate('[type=submit]', 'click', function() {
- if ($(this).closest('form').is('[pjax-container]')) {
- let isSubmited = $(this).attr('disabled') == 'disabled';
- $(this).addClass('disabled').attr('disabled', true);
- !isSubmited && $(this).closest('form[pjax-container]').submit();
- }
- });
- $(document).on('submit', 'form[pjax-container]', function(event) {
- });
- $(document).click(function() {
- $('.sidebar-form .dropdown-menu').hide();
- });
- $(function() {
- $('.sidebar-menu li:not(.treeview) > a').on('click', function() {
- var $parent = $(this).parent().addClass('active');
- $parent.siblings('.treeview.active').find('> a').trigger('click');
- $parent.siblings().removeClass('active').find('li').removeClass('active');
- });
- var menu = $('.sidebar-menu li > a[href$="' + (location.pathname + location.search + location.hash) + '"]').parent().addClass('active');
- menu.parents('ul.treeview-menu').addClass('menu-open');
- menu.parents('li.treeview').addClass('active');
- $.AdminLTE.layout.fix();
- $('[data-toggle="popover"]').popover();
- $('.sidebar-form .autocomplete').on('keyup focus', function() {
- var $menu = $('.sidebar-form .dropdown-menu');
- var text = $(this).val();
- if (text === '') {
- $menu.hide();
- return;
- }
- var regex = new RegExp(text,'i');
- var matched = false;
- $menu.find('li').each(function() {
- if (!regex.test($(this).find('a').text())) {
- $(this).hide();
- } else {
- $(this).show();
- matched = true;
- }
- });
- if (matched) {
- $menu.show();
- }
- }).click(function(event) {
- event.stopPropagation();
- });
- $('.sidebar-form .dropdown-menu li a').click(function() {
- $('.sidebar-form .autocomplete').val($(this).text());
- });
- });
- $(window).scroll(function() {
- if (document.body.scrollTop > 100 || document.documentElement.scrollTop > 100) {
- $('#totop').fadeIn(500);
- } else {
- $('#totop').fadeOut(500);
- }
- });
- $('#totop').on('click', function(e) {
- e.preventDefault();
- $('html,body').animate({
- scrollTop: 0
- }, 500);
- });
- (function($) {
- var Grid = function() {
- this.selects = {};
- };
- Grid.prototype.select = function(id) {
- this.selects[id] = id;
- }
- ;
- Grid.prototype.unselect = function(id) {
- delete this.selects[id];
- }
- ;
- Grid.prototype.selected = function() {
- var rows = [];
- $.each(this.selects, function(key, val) {
- rows.push(key);
- });
- return rows;
- }
- ;
- ;
- $.admin.redirect = function(url) {
- $.admin.grid = new Grid();
- }
- ;
- $.admin.getToken = function() {
- return $('meta[name="csrf-token"]').attr('content');
- }
- ;
- $.admin.loadedScripts = [];
- $.admin.loadScripts = function(arr) {
- var _arr = $.map(arr, function(src) {
- if ($.inArray(src, $.admin.loadedScripts)) {
- return;
- }
- $.admin.loadedScripts.push(src);
- return $.getScript(src);
- });
- _arr.push($.Deferred(function(deferred) {
- $(deferred.resolve);
- }));
- return $.when.apply($, _arr);
- }
- }
- )(jQuery);
|