增加lgbTooltip方法包装原生态tooltip方法,方便调用

This commit is contained in:
Argo-Surface 2017-01-14 18:05:55 +08:00 committed by Argo-Lenovo
parent 717d29f028
commit 1836953005
9 changed files with 23 additions and 15 deletions

View File

@ -240,6 +240,13 @@
}); });
that.animate({ marginTop: "+=" + getHeight() }); 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) { autoValidate: function (rules, messages, handler) {
var parent = 'body'; var parent = 'body';
var $wrapper = $('#dialogNew'); var $wrapper = $('#dialogNew');
@ -263,13 +270,13 @@
$(element).parents('.form-group').addClass(errorClass).removeClass(validClass); $(element).parents('.form-group').addClass(errorClass).removeClass(validClass);
}, },
unhighlight: function (element, errorClass, 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) { errorPlacement: function (label, element) {
var $ele = $(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.attr('data-original-title', $(label).text());
$ele.tooltip('show') $ele.lgbTooltip('show')
} }
}); });
if (handler && $.isArray(handler.button)) { if (handler && $.isArray(handler.button)) {

View File

@ -55,7 +55,7 @@ $(function () {
scrollTop: 0 scrollTop: 0
}, 200); }, 200);
}); });
if (!$.browser.versions.mobile) $('[role="tooltip"]').tooltip({ delay: { "show": 500, "hide": 100 } }); if (!$.browser.versions.mobile) $('[role="tooltip"]').lgbTooltip();
// breadcrumb // breadcrumb
var arch = $('#nav-accordion').find('a.active').last(); var arch = $('#nav-accordion').find('a.active').last();

View File

@ -31,6 +31,7 @@
if (that.options.validateForm && that.options.validateForm.constructor === String) { if (that.options.validateForm && that.options.validateForm.constructor === String) {
var v = $('#' + that.options.validateForm); var v = $('#' + that.options.validateForm);
v.validate().resetForm(); v.validate().resetForm();
v.find('[data-original-title]').lgbTooltip('destroy');
v.find('.has-error, .has-success').removeClass("has-error has-success"); v.find('.has-error, .has-success').removeClass("has-error has-success");
} }
}); });

View File

@ -29,7 +29,7 @@
$dialogRoleHeader.text($.format('{0}-角色授权窗口', row.GroupName)); $dialogRoleHeader.text($.format('{0}-角色授权窗口', row.GroupName));
$dialogRoleForm.html(html).find('[role="tooltip"]').each(function (index, label) { $dialogRoleForm.html(html).find('[role="tooltip"]').each(function (index, label) {
if (label.title == "") label.title = "未设置"; if (label.title == "") label.title = "未设置";
}).tooltip({ container: 'body', delay: { "show": 500, "hide": 100 } }); }).lgbTooltip();
$dialogRole.modal('show'); $dialogRole.modal('show');
} }
}); });
@ -47,7 +47,7 @@
$dialogUserHeader.text($.format('{0}-用户授权窗口', row.GroupName)); $dialogUserHeader.text($.format('{0}-用户授权窗口', row.GroupName));
$dialogUserForm.html(html).find('[role="tooltip"]').each(function (index, label) { $dialogUserForm.html(html).find('[role="tooltip"]').each(function (index, label) {
if (label.title == "") label.title = "未设置"; if (label.title == "") label.title = "未设置";
}).tooltip({ container: 'body', delay: { "show": 500, "hide": 100 } }); }).lgbTooltip();
$dialogUser.modal('show'); $dialogUser.modal('show');
} }
}); });

View File

@ -50,7 +50,7 @@
$dialogRoleHeader.text($.format('{0}-角色授权窗口', row.Name)); $dialogRoleHeader.text($.format('{0}-角色授权窗口', row.Name));
$dialogRoleForm.html(html).find('[role="tooltip"]').each(function (index, label) { $dialogRoleForm.html(html).find('[role="tooltip"]').each(function (index, label) {
if (label.title == "") label.title = "未设置"; if (label.title == "") label.title = "未设置";
}).tooltip({ container: 'body', delay: { "show": 500, "hide": 100 } }); }).lgbTooltip();
$dialogRole.modal('show'); $dialogRole.modal('show');
} }
}); });

View File

@ -149,7 +149,7 @@
}).join(''); }).join('');
$sortable.append($.format('<li class="title">{0}-{1}</li>', options.item.Desc, options.item.Key)); $sortable.append($.format('<li class="title">{0}-{1}</li>', options.item.Desc, options.item.Key));
$sortable.append(content); $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'); $('#refreshCache').click(function () { listCacheUrl(); }).trigger('click');
$('#clearCache').click(function () { listCacheUrl({ clear: true }); }); $('#clearCache').click(function () { listCacheUrl({ clear: true }); });
$sortable.on('click', '.btn', function () { $sortable.on('click', '.btn', function () {
$(this).tooltip('destroy'); $(this).lgbTooltip('destroy');
listCache({ key: $(this).attr('data-key'), url: $(this).attr('data-url') }); listCache({ key: $(this).attr('data-key'), url: $(this).attr('data-url') });
listCacheUrl(); listCacheUrl();
}); });

View File

@ -35,7 +35,7 @@
$dialogUserHeader.text($.format('{0}-用户授权窗口', row.RoleName)); $dialogUserHeader.text($.format('{0}-用户授权窗口', row.RoleName));
$dialogUserForm.html(html).find('[role="tooltip"]').each(function (index, label) { $dialogUserForm.html(html).find('[role="tooltip"]').each(function (index, label) {
if (label.title == "") label.title = "未设置"; if (label.title == "") label.title = "未设置";
}).tooltip({ container: 'body', delay: { "show": 500, "hide": 100 } }); }).lgbTooltip();
$dialogUser.modal('show'); $dialogUser.modal('show');
} }
}); });
@ -53,7 +53,7 @@
$dialogGroupHeader.text($.format('{0}-部门授权窗口', row.RoleName)); $dialogGroupHeader.text($.format('{0}-部门授权窗口', row.RoleName));
$dialogGroupForm.html(html).find('[role="tooltip"]').each(function (index, label) { $dialogGroupForm.html(html).find('[role="tooltip"]').each(function (index, label) {
if (label.title == "") label.title = "未设置"; if (label.title == "") label.title = "未设置";
}).tooltip({ container: 'body', delay: { "show": 500, "hide": 100 } }); }).lgbTooltip();
$dialogGroup.modal('show'); $dialogGroup.modal('show');
} }
}); });

View File

@ -31,7 +31,7 @@
$dialogRoleHeader.text($.format('{0}-角色授权窗口', row.DisplayName)); $dialogRoleHeader.text($.format('{0}-角色授权窗口', row.DisplayName));
$dialogRoleForm.html(html).find('[role="tooltip"]').each(function (index, label) { $dialogRoleForm.html(html).find('[role="tooltip"]').each(function (index, label) {
if (label.title == "") label.title = "未设置"; if (label.title == "") label.title = "未设置";
}).tooltip({ container: 'body', delay: { "show": 500, "hide": 100 } }); }).lgbTooltip();
$dialogRole.modal('show'); $dialogRole.modal('show');
} }
}); });
@ -49,7 +49,7 @@
$dialogGroupHeader.text($.format('{0}-部门授权窗口', row.DisplayName)); $dialogGroupHeader.text($.format('{0}-部门授权窗口', row.DisplayName));
$dialogGroupForm.html(html).find('[role="tooltip"]').each(function (index, label) { $dialogGroupForm.html(html).find('[role="tooltip"]').each(function (index, label) {
if (label.title == "") label.title = "未设置"; if (label.title == "") label.title = "未设置";
}).tooltip({ container: 'body', delay: { "show": 500, "hide": 100 } }); }).lgbTooltip();
$dialogGroup.modal('show'); $dialogGroup.modal('show');
} }
}); });

View File

@ -15,7 +15,7 @@
return $.format(htmlNewUsers, noti.UserName, noti.Description, noti.RegisterTime, noti.ID, noti.DisplayName); return $.format(htmlNewUsers, noti.UserName, noti.Description, noti.RegisterTime, noti.ID, noti.DisplayName);
}).join(''); }).join('');
$taskUsers.append(content); $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'); $btnRefreshUser.toggleClass('fa-spin');
} }
@ -26,7 +26,7 @@
$btnRefreshUser.on('click', function () { $btnRefreshUser.on('click', function () {
listData(); 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 () { $('#tasks-users').on('click', 'button', function () {
var id = $(this).attr('data-id'); var id = $(this).attr('data-id');