Parcourir la source

规范前端代码

jqh il y a 5 ans
Parent
commit
5ba5c45398

+ 1 - 1
src/Extension/Grid/ImportButton.php

@@ -31,7 +31,7 @@ HTML;
 
         Admin::script(
             <<<JS
-$('.import-extension').click(function () {
+$('.import-extension').on('click', function () {
     var id = $(this).data('id'), req;
     if (req) return;
     

+ 1 - 1
src/Form/Field/Captcha.php

@@ -32,7 +32,7 @@ class Captcha extends Text
     public function render()
     {
         $this->script = <<<'JS'
-$('.field-refresh-captcha').off('click').click(function () {
+$('.field-refresh-captcha').off('click').on('click', function () {
     $(this).attr('src', $(this).attr('data-url')+'?'+Math.random());
 });
 JS;

+ 1 - 1
src/Form/Field/Fieldset.php

@@ -16,7 +16,7 @@ class Fieldset
     public function start($title)
     {
         $script = <<<JS
-$('.{$this->name}-title').click(function () {
+$('.{$this->name}-title').on('click', function () {
     $("i", this).toggleClass("fa-angle-double-down fa-angle-double-up");
 });
 JS;

+ 1 - 1
src/Form/Field/Icon.php

@@ -31,7 +31,7 @@ setTimeout(function () {
     
     field.iconpicker({placement:'bottomLeft', animation: false});
     
-    parent.find('.iconpicker-item').click(function (e) {
+    parent.find('.iconpicker-item').on('click', function (e) {
        showIcon($(this).find('i').attr('class'));
     });
     

+ 1 - 1
src/Grid/Column/Filter/Between.php

@@ -150,7 +150,7 @@ JS
         }
 
         $script = <<<'JS'
-$('.dropdown-menu input').click(function(e) {
+$('.dropdown-menu input').on('click', function(e) {
     e.stopPropagation();
 });
 JS;

+ 1 - 1
src/Grid/Column/Filter/Input.php

@@ -17,7 +17,7 @@ trait Input
     protected function addScript()
     {
         $script = <<<'JS'
-$('.dropdown-menu input').click(function(e) {
+$('.dropdown-menu input').on('click', function(e) {
     e.stopPropagation();
 });
 JS;

+ 1 - 1
src/Grid/Displayers/Copyable.php

@@ -14,7 +14,7 @@ class Copyable extends AbstractDisplayer
     protected function addScript()
     {
         $script = <<<'JS'
-$('.grid-column-copyable').off('click').click(function (e) {
+$('.grid-column-copyable').off('click').on('click', function (e) {
     
     var content = $(this).data('content');
     

+ 1 - 1
src/Grid/Displayers/DialogTree.php

@@ -185,7 +185,7 @@ EOF;
 
         Admin::script(
             <<<JS
-$('.{$this->getSelectorPrefix()}-open-tree').off('click').click(function () {
+$('.{$this->getSelectorPrefix()}-open-tree').off('click').on('click', function () {
     var tpl = '<div class="jstree-wrapper p-1" style="border:0"><div class="da-tree" style="margin-top:10px"></div></div>', 
         opts = $opts,
         url = '{$this->url}',

+ 1 - 1
src/Grid/Displayers/Expand.php

@@ -65,7 +65,7 @@ EOT;
     protected function setupScript()
     {
         $script = <<<'JS'
-$('.grid-expand').off('click').click(function () {
+$('.grid-expand').off('click').on('click', function () {
     
     if ($(this).data('inserted') == '0') {
     

+ 1 - 1
src/Grid/Filter/Group.php

@@ -285,7 +285,7 @@ class Group extends AbstractFilter
     protected function injectScript()
     {
         $script = <<<JS
-$(".{$this->name} li a").click(function(){
+$(".{$this->name} li a").on('click', function(){
     $(".{$this->name}-label").text($(this).text());
     $(".{$this->name}-operation").val($(this).data('index'));
 });

+ 1 - 1
src/Grid/Tools/ExportButton.php

@@ -29,7 +29,7 @@ class ExportButton implements Renderable
     protected function setUpScripts()
     {
         $script = <<<JS
-$('.{$this->grid->getExportSelectedName()}').click(function (e) {
+$('.{$this->grid->getExportSelectedName()}').on('click', function (e) {
     e.preventDefault();
     
     var rows = Dcat.grid.selected('{$this->grid->getName()}').join(',');

+ 3 - 3
src/Grid/Tools/FilterButton.php

@@ -71,7 +71,7 @@ class FilterButton extends AbstractTool
     
     expand && setTimeout(initSlider, 10);
     
-    $('.{$this->getElementClassName()}').click(function () {
+    $('.{$this->getElementClassName()}').on('click', function () {
         if (! slider) {
             initSlider()
         }
@@ -80,14 +80,14 @@ class FilterButton extends AbstractTool
         return false
     });
     
-    $('#{$id} .close-slider').click(function () {
+    $('#{$id} .close-slider').on('click', function () {
         slider.close()
     })
 })();
 JS;
         } else {
             $script = <<<JS
-$('.{$this->getElementClassName()}').click(function(){
+$('.{$this->getElementClassName()}').on('click', function(){
     $('#{$id}').parent().collapse('toggle');
 }); 
 JS;

+ 3 - 3
src/Grid/Tools/QuickCreate.php

@@ -272,16 +272,16 @@ class QuickCreate implements Renderable
     var ctr = $('.{$this->getElementClass()}'),
         btn = $('.quick-create-button-{$uniqueName}');
     
-    btn.click(function () {
+    btn.on('click', function () {
         ctr.toggle().click();
     });
     
-    ctr.click(function () {
+    ctr.on('click', function () {
         ctr.find('.create-form').show();
         ctr.find('.create').hide();
     });
     
-    ctr.find('.cancel').click(function () {
+    ctr.find('.cancel').on('click', function () {
         if (btn.length) {
             ctr.hide();
             return;

+ 1 - 1
src/Grid/Tools/QuickSearch.php

@@ -162,7 +162,7 @@ class QuickSearch extends AbstractTool
         });
     val !== '' && $ipt.val('').focus().val(val);
     
-    $('.quick-search-clear').click(function () {
+    $('.quick-search-clear').on('click', function () {
         $(this).parent().find('.quick-search-input').val('');
     
         $(this).closest('form').submit();

+ 1 - 1
src/Traits/InteractsWithApi.php

@@ -248,7 +248,7 @@ JS;
 
         foreach ($this->requestSelectors as $v) {
             $script .= <<<JS
-$('{$v}').click(function () { 
+$('{$v}').on('click', function () { 
     request($(this).data()) 
 });
 JS;

+ 1 - 1
src/Tree.php

@@ -366,7 +366,7 @@ class Tree implements Renderable
     
     tree.nestable($nestableOptions);
 
-    $('.{$this->elementId}-save').click(function () {
+    $('.{$this->elementId}-save').on('click', function () {
         var serialize = tree.nestable('serialize'), _this = $(this);
         _this.buttonLoading();
         $.post('{$this->url}', {

+ 1 - 1
src/Widgets/Dropdown.php

@@ -331,7 +331,7 @@ HTML
                 <<<JS
 (function () {
     var btn = $('#{$this->buttonId}'), _a = btn.parent().find('ul li a'), text = '$label';                
-    _a.click(function () {
+    _a.on('click', function () {
         btn.find('stub').html($(this).html() + ' &nbsp;');
     });
     if (text) {

+ 1 - 1
src/Widgets/Metrics/Card.php

@@ -471,7 +471,7 @@ JS
 
         // 按钮显示选中文本
         return <<<JS
-$('{$clickable}').click(function () {
+$('{$clickable}').on('click', function () {
     $(this).parents('.dropdown').find('.btn').html($(this).text());
 });
 

+ 1 - 1
src/Widgets/NavList.php

@@ -64,7 +64,7 @@ class NavList extends Widget
         if ($this->click) {
             Admin::script(
                 <<<JS
-$('#{$this->id} li').click(function () {
+$('#{$this->id} li').on('click', function () {
     $('#{$this->id} li').removeClass('active');
     $(this).addClass('active');
 });

+ 1 - 1
src/Widgets/Navbar.php

@@ -138,7 +138,7 @@ class Navbar extends Widget
         if ($this->click) {
             Admin::script(
                 <<<JS
-$('#{$this->id} li.nav-li').click(function () {
+$('#{$this->id} li.nav-li').on('click', function () {
     $('#{$this->id} li.nav-li').removeClass('active');
     $(this).addClass('active');
 });