From 18369530057eaaca67d76446c07e6335701fc10c Mon Sep 17 00:00:00 2001 From: Argo-Surface Date: Sat, 14 Jan 2017 18:05:55 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0lgbTooltip=E6=96=B9=E6=B3=95?= =?UTF-8?q?=E5=8C=85=E8=A3=85=E5=8E=9F=E7=94=9F=E6=80=81tooltip=E6=96=B9?= =?UTF-8?q?=E6=B3=95=EF=BC=8C=E6=96=B9=E4=BE=BF=E8=B0=83=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Bootstrap.Admin/Content/js/Longbow.Common.js | 13 ++++++++++--- Bootstrap.Admin/Content/js/common-scripts.js | 2 +- Bootstrap.Admin/Content/js/framework.js | 1 + Bootstrap.Admin/Scripts/Groups.js | 4 ++-- Bootstrap.Admin/Scripts/Menus.js | 2 +- Bootstrap.Admin/Scripts/Profiles.js | 4 ++-- Bootstrap.Admin/Scripts/Roles.js | 4 ++-- Bootstrap.Admin/Scripts/Users.js | 4 ++-- Bootstrap.Admin/Scripts/noti.js | 4 ++-- 9 files changed, 23 insertions(+), 15 deletions(-) diff --git a/Bootstrap.Admin/Content/js/Longbow.Common.js b/Bootstrap.Admin/Content/js/Longbow.Common.js index f955b5ca..97a762b0 100644 --- a/Bootstrap.Admin/Content/js/Longbow.Common.js +++ b/Bootstrap.Admin/Content/js/Longbow.Common.js @@ -240,6 +240,13 @@ }); that.animate({ marginTop: "+=" + getHeight() }); }, + lgbTooltip: function (option) { + if (option == undefined) option = { container: 'body', delay: { "show": 500, "hide": 100 } }; + else if (typeof option == "object") option = $.extend({ container: 'body', delay: { "show": 500, "hide": 100 } }, option); + $(this).tooltip(option); + if (option == 'destroy') $(this).removeAttr('data-original-title'); + return this; + }, autoValidate: function (rules, messages, handler) { var parent = 'body'; var $wrapper = $('#dialogNew'); @@ -263,13 +270,13 @@ $(element).parents('.form-group').addClass(errorClass).removeClass(validClass); }, unhighlight: function (element, errorClass, validClass) { - $(element).tooltip('destroy').removeAttr('data-original-title').parents('.form-group').removeClass(errorClass).addClass(validClass); + $(element).lgbTooltip('destroy').parents('.form-group').removeClass(errorClass).addClass(validClass); }, errorPlacement: function (label, element) { var $ele = $(element); - if (!$ele.attr('data-original-title')) $ele.tooltip({ container: parent, delay: { "show": 500, "hide": 100 } }); + if (!$ele.attr('data-original-title')) $ele.lgbTooltip({ container: parent }); $ele.attr('data-original-title', $(label).text()); - $ele.tooltip('show') + $ele.lgbTooltip('show') } }); if (handler && $.isArray(handler.button)) { diff --git a/Bootstrap.Admin/Content/js/common-scripts.js b/Bootstrap.Admin/Content/js/common-scripts.js index f8b82da7..33cdf12b 100644 --- a/Bootstrap.Admin/Content/js/common-scripts.js +++ b/Bootstrap.Admin/Content/js/common-scripts.js @@ -55,7 +55,7 @@ $(function () { scrollTop: 0 }, 200); }); - if (!$.browser.versions.mobile) $('[role="tooltip"]').tooltip({ delay: { "show": 500, "hide": 100 } }); + if (!$.browser.versions.mobile) $('[role="tooltip"]').lgbTooltip(); // breadcrumb var arch = $('#nav-accordion').find('a.active').last(); diff --git a/Bootstrap.Admin/Content/js/framework.js b/Bootstrap.Admin/Content/js/framework.js index 61b0117f..cc4c1e9a 100644 --- a/Bootstrap.Admin/Content/js/framework.js +++ b/Bootstrap.Admin/Content/js/framework.js @@ -31,6 +31,7 @@ if (that.options.validateForm && that.options.validateForm.constructor === String) { var v = $('#' + that.options.validateForm); v.validate().resetForm(); + v.find('[data-original-title]').lgbTooltip('destroy'); v.find('.has-error, .has-success').removeClass("has-error has-success"); } }); diff --git a/Bootstrap.Admin/Scripts/Groups.js b/Bootstrap.Admin/Scripts/Groups.js index a67dfb75..2d15fce3 100644 --- a/Bootstrap.Admin/Scripts/Groups.js +++ b/Bootstrap.Admin/Scripts/Groups.js @@ -29,7 +29,7 @@ $dialogRoleHeader.text($.format('{0}-角色授权窗口', row.GroupName)); $dialogRoleForm.html(html).find('[role="tooltip"]').each(function (index, label) { if (label.title == "") label.title = "未设置"; - }).tooltip({ container: 'body', delay: { "show": 500, "hide": 100 } }); + }).lgbTooltip(); $dialogRole.modal('show'); } }); @@ -47,7 +47,7 @@ $dialogUserHeader.text($.format('{0}-用户授权窗口', row.GroupName)); $dialogUserForm.html(html).find('[role="tooltip"]').each(function (index, label) { if (label.title == "") label.title = "未设置"; - }).tooltip({ container: 'body', delay: { "show": 500, "hide": 100 } }); + }).lgbTooltip(); $dialogUser.modal('show'); } }); diff --git a/Bootstrap.Admin/Scripts/Menus.js b/Bootstrap.Admin/Scripts/Menus.js index a1c8ed21..9fb26e1b 100644 --- a/Bootstrap.Admin/Scripts/Menus.js +++ b/Bootstrap.Admin/Scripts/Menus.js @@ -50,7 +50,7 @@ $dialogRoleHeader.text($.format('{0}-角色授权窗口', row.Name)); $dialogRoleForm.html(html).find('[role="tooltip"]').each(function (index, label) { if (label.title == "") label.title = "未设置"; - }).tooltip({ container: 'body', delay: { "show": 500, "hide": 100 } }); + }).lgbTooltip(); $dialogRole.modal('show'); } }); diff --git a/Bootstrap.Admin/Scripts/Profiles.js b/Bootstrap.Admin/Scripts/Profiles.js index 385edf4f..eadec430 100644 --- a/Bootstrap.Admin/Scripts/Profiles.js +++ b/Bootstrap.Admin/Scripts/Profiles.js @@ -149,7 +149,7 @@ }).join(''); $sortable.append($.format('
  • {0}-{1}
  • ', options.item.Desc, options.item.Key)); $sortable.append(content); - if (!$.browser.versions.mobile) $sortable.find('[role="tooltip"]').tooltip({ container: 'body', delay: { "show": 500, "hide": 100 } }); + if (!$.browser.versions.mobile) $sortable.find('[role="tooltip"]').lgbTooltip(); } } } @@ -158,7 +158,7 @@ $('#refreshCache').click(function () { listCacheUrl(); }).trigger('click'); $('#clearCache').click(function () { listCacheUrl({ clear: true }); }); $sortable.on('click', '.btn', function () { - $(this).tooltip('destroy'); + $(this).lgbTooltip('destroy'); listCache({ key: $(this).attr('data-key'), url: $(this).attr('data-url') }); listCacheUrl(); }); diff --git a/Bootstrap.Admin/Scripts/Roles.js b/Bootstrap.Admin/Scripts/Roles.js index 431aaec3..387b205a 100644 --- a/Bootstrap.Admin/Scripts/Roles.js +++ b/Bootstrap.Admin/Scripts/Roles.js @@ -35,7 +35,7 @@ $dialogUserHeader.text($.format('{0}-用户授权窗口', row.RoleName)); $dialogUserForm.html(html).find('[role="tooltip"]').each(function (index, label) { if (label.title == "") label.title = "未设置"; - }).tooltip({ container: 'body', delay: { "show": 500, "hide": 100 } }); + }).lgbTooltip(); $dialogUser.modal('show'); } }); @@ -53,7 +53,7 @@ $dialogGroupHeader.text($.format('{0}-部门授权窗口', row.RoleName)); $dialogGroupForm.html(html).find('[role="tooltip"]').each(function (index, label) { if (label.title == "") label.title = "未设置"; - }).tooltip({ container: 'body', delay: { "show": 500, "hide": 100 } }); + }).lgbTooltip(); $dialogGroup.modal('show'); } }); diff --git a/Bootstrap.Admin/Scripts/Users.js b/Bootstrap.Admin/Scripts/Users.js index 19abe3c0..8dce0c0a 100644 --- a/Bootstrap.Admin/Scripts/Users.js +++ b/Bootstrap.Admin/Scripts/Users.js @@ -31,7 +31,7 @@ $dialogRoleHeader.text($.format('{0}-角色授权窗口', row.DisplayName)); $dialogRoleForm.html(html).find('[role="tooltip"]').each(function (index, label) { if (label.title == "") label.title = "未设置"; - }).tooltip({ container: 'body', delay: { "show": 500, "hide": 100 } }); + }).lgbTooltip(); $dialogRole.modal('show'); } }); @@ -49,7 +49,7 @@ $dialogGroupHeader.text($.format('{0}-部门授权窗口', row.DisplayName)); $dialogGroupForm.html(html).find('[role="tooltip"]').each(function (index, label) { if (label.title == "") label.title = "未设置"; - }).tooltip({ container: 'body', delay: { "show": 500, "hide": 100 } }); + }).lgbTooltip(); $dialogGroup.modal('show'); } }); diff --git a/Bootstrap.Admin/Scripts/noti.js b/Bootstrap.Admin/Scripts/noti.js index 8277535c..754af077 100644 --- a/Bootstrap.Admin/Scripts/noti.js +++ b/Bootstrap.Admin/Scripts/noti.js @@ -15,7 +15,7 @@ return $.format(htmlNewUsers, noti.UserName, noti.Description, noti.RegisterTime, noti.ID, noti.DisplayName); }).join(''); $taskUsers.append(content); - if (!$.browser.versions.mobile) $('#tasks-users').find('[role="tooltip"]').tooltip({ delay: { "show": 500, "hide": 100 } }); + if (!$.browser.versions.mobile) $('#tasks-users').find('[role="tooltip"]').lgbTooltip(); } $btnRefreshUser.toggleClass('fa-spin'); } @@ -26,7 +26,7 @@ $btnRefreshUser.on('click', function () { listData(); }); - if (!$.browser.versions.mobile) $btnRefreshUser.tooltip({ container: 'body', delay: { "show": 500, "hide": 100 } }); + if (!$.browser.versions.mobile) $btnRefreshUser.lgbTooltip(); $('#tasks-users').on('click', 'button', function () { var id = $(this).attr('data-id');