toastr_notifications.html 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>H+ 后台主题UI框架 - Toastr通知</title>
  7. <meta name="keywords" content="H+后台主题,后台bootstrap框架,会员中心主题,后台HTML,响应式后台">
  8. <meta name="description" content="H+是一个完全响应式,基于Bootstrap3最新版本开发的扁平化主题,她采用了主流的左右两栏式布局,使用了Html5+CSS3等现代技术">
  9. <link rel="shortcut icon" href="favicon.ico"> <link href="css/bootstrap.min.css?v=3.3.7" rel="stylesheet">
  10. <link href="css/font-awesome.css?v=4.4.0" rel="stylesheet">
  11. <link href="css/animate.css" rel="stylesheet">
  12. <link href="css/style.css?v=4.1.0" rel="stylesheet">
  13. <link href="css/plugins/toastr/toastr.min.css" rel="stylesheet">
  14. </head>
  15. <body class="gray-bg">
  16. <div class="row">
  17. <div class="col-lg-12">
  18. <div class="wrapper wrapper-content">
  19. <div class="row">
  20. <div class="col-lg-12">
  21. <div class="ibox float-e-margins">
  22. <div class="ibox-title">
  23. <h5>Toastr示例</h5>
  24. <div class="ibox-tools">
  25. <a class="collapse-link">
  26. <i class="fa fa-chevron-up"></i>
  27. </a>
  28. <a class="dropdown-toggle" data-toggle="dropdown" href="#">
  29. <i class="fa fa-wrench"></i>
  30. </a>
  31. <ul class="dropdown-menu dropdown-user">
  32. <li><a href="#">设置选项1</a>
  33. </li>
  34. <li><a href="#">设置选项2</a>
  35. </li>
  36. </ul>
  37. <a class="close-link">
  38. <i class="fa fa-times"></i>
  39. </a>
  40. </div>
  41. </div>
  42. <div class="ibox-content">
  43. <div class="row">
  44. <div class="col-md-4">
  45. <div class="form-group">
  46. <label for="title">标题</label>
  47. <input id="title" type="text" class="form-control" placeholder="请输入标题...">
  48. </div>
  49. <div class="form-group">
  50. <label for="message">消息</label>
  51. <textarea class="form-control" id="message" rows="3" placeholder="请输入消息..."></textarea>
  52. </div>
  53. <div class="checkbox">
  54. <label class="checkbox" for="closeButton">
  55. <input id="closeButton" type="checkbox" value="checked" class="input-mini" checked="">关闭按钮
  56. </label>
  57. </div>
  58. <div class="checkbox">
  59. <label class="checkbox" for="addBehaviorOnToastClick">
  60. <input id="addBehaviorOnToastClick" type="checkbox" value="checked" class="input-mini">添加Toast单击行为
  61. </label>
  62. </div>
  63. <div class="checkbox">
  64. <label class="checkbox" for="debugInfo">
  65. <input id="debugInfo" type="checkbox" value="checked" class="input-mini">Debug
  66. </label>
  67. </div>
  68. <div class="checkbox">
  69. <label class="checkbox" for="progressBar">
  70. <input id="progressBar" type="checkbox" value="checked" class="input-mini" checked="">进度条
  71. </label>
  72. </div>
  73. <div class="checkbox">
  74. <label class="checkbox" for="preventDuplicates">
  75. <input id="preventDuplicates" type="checkbox" value="checked" class="input-mini">防止重复
  76. </label>
  77. </div>
  78. </div>
  79. <div class="col-md-2">
  80. <div class="form-group" id="toastTypeGroup">
  81. <label>Toast类型</label>
  82. <div class="radio">
  83. <label>
  84. <input type="radio" name="toasts" value="success" checked="">成功
  85. </label>
  86. </div>
  87. <div class="radio">
  88. <label class="radio">
  89. <input type="radio" name="toasts" value="info">信息
  90. </label>
  91. </div>
  92. <div class="radio">
  93. <label class="radio">
  94. <input type="radio" name="toasts" value="warning">警告
  95. </label>
  96. </div>
  97. <div class="radio">
  98. <label class="radio">
  99. <input type="radio" name="toasts" value="error">错误
  100. </label>
  101. </div>
  102. </div>
  103. <div class="form-group" id="positionGroup">
  104. <label>Position</label>
  105. <div class="radio">
  106. <label>
  107. <input type="radio" name="positions" value="toast-top-right" checked="">右上
  108. </label>
  109. </div>
  110. <div class="radio">
  111. <label>
  112. <input type="radio" name="positions" value="toast-bottom-right">右下
  113. </label>
  114. </div>
  115. <div class="radio">
  116. <label>
  117. <input type="radio" name="positions" value="toast-bottom-left">左下
  118. </label>
  119. </div>
  120. <div class="radio">
  121. <label>
  122. <input type="radio" name="positions" value="toast-top-left">左上
  123. </label>
  124. </div>
  125. <div class="radio">
  126. <label>
  127. <input type="radio" name="positions" value="toast-top-full-width">顶部全宽
  128. </label>
  129. </div>
  130. <div class="radio">
  131. <label>
  132. <input type="radio" name="positions" value="toast-bottom-full-width">底部全宽
  133. </label>
  134. </div>
  135. <div class="radio">
  136. <label>
  137. <input type="radio" name="positions" value="toast-top-center">顶部居中
  138. </label>
  139. </div>
  140. <div class="radio">
  141. <label>
  142. <input type="radio" name="positions" value="toast-bottom-center">底部居中
  143. </label>
  144. </div>
  145. </div>
  146. </div>
  147. <div class="col-md-2">
  148. <div class="form-group">
  149. <label for="showEasing">显示动画</label>
  150. <input id="showEasing" type="text" placeholder="swing, linear" class="form-control" value="swing">
  151. </div>
  152. <div class="form-group">
  153. <label for="hideEasing">隐藏动画</label>
  154. <input id="hideEasing" type="text" placeholder="swing, linear" class="form-control" value="linear">
  155. </div>
  156. <div class="form-group">
  157. <label for="showMethod">显示方法</label>
  158. <input id="showMethod" type="text" placeholder="show, fadeIn, slideDown" class="form-control" value="fadeIn">
  159. </div>
  160. <div class="form-group">
  161. <label for="hideMethod">隐藏方法</label>
  162. <input id="hideMethod" type="text" placeholder="hide, fadeOut, slideUp" class="form-control" value="fadeOut">
  163. </div>
  164. </div>
  165. <div class="col-md-3">
  166. <div class="form-group">
  167. <label for="showDuration">显示持续时间</label>
  168. <input id="showDuration" type="text" placeholder="ms" class="form-control" value="400">
  169. </div>
  170. <div class="form-group">
  171. <label for="hideDuration">隐藏持续时间</label>
  172. <input id="hideDuration" type="text" placeholder="ms" class="form-control" value="1000">
  173. </div>
  174. <div class="form-group">
  175. <label for="timeOut">超时</label>
  176. <input id="timeOut" type="text" placeholder="ms" class="form-control" value="7000">
  177. </div>
  178. <div class="form-group">
  179. <label for="extendedTimeOut">延长时间</label>
  180. <input id="extendedTimeOut" type="text" placeholder="ms" class="form-control" value="1000">
  181. </div>
  182. </div>
  183. </div>
  184. <div class="row">
  185. <div class="col-lg-12">
  186. <button type="button" class="btn btn-primary" id="showtoast">显示Toast</button>
  187. <button type="button" class="btn btn-white" id="cleartoasts">清除所有Toast</button>
  188. <button type="button" class="btn btn-white" id="clearlasttoast">清除最后一个Toast</button>
  189. <button type="button" class="btn btn-white" id="showsimple">显示简单设置</button>
  190. </div>
  191. </div>
  192. <div class="row m-t-lg">
  193. <div class="col-lg-12">
  194. <small>Toastr JSON设置</small>
  195. <pre id="toastrOptions" class="p-m">Command: toastr[success]("Hi, welcome to hplus. This is example of Toastr notification box.")
  196. toastr.options = {
  197. "closeButton": true,
  198. "debug": true,
  199. "progressBar": false,
  200. "positionClass": "toast-top-right",
  201. "showDuration": "400",
  202. "hideDuration": "1000",
  203. "timeOut": "7000",
  204. "extendedTimeOut": "1000",
  205. "showEasing": "swing",
  206. "hideEasing": "linear",
  207. "showMethod": "fadeIn",
  208. "hideMethod": "fadeOut"
  209. }</pre>
  210. </div>
  211. </div>
  212. </div>
  213. </div>
  214. </div>
  215. </div>
  216. </div>
  217. </div>
  218. </div>
  219. <!-- 全局js -->
  220. <script src="js/jquery.min.js?v=2.1.4"></script>
  221. <script src="js/bootstrap.min.js?v=3.3.7"></script>
  222. <!-- 自定义js -->
  223. <script src="js/content.js?v=1.0.0"></script>
  224. <!-- Toastr script -->
  225. <script src="js/plugins/toastr/toastr.min.js"></script>
  226. <script type="text/javascript">
  227. $(function () {
  228. var i = -1;
  229. var toastCount = 0;
  230. var $toastlast;
  231. var getMessage = function () {
  232. var msg = 'Hi, welcome to Inspinia. This is example of Toastr notification box.';
  233. return msg;
  234. };
  235. $('#showsimple').click(function () {
  236. // Display a success toast, with a title
  237. toastr.success('Without any options', 'Simple notification!')
  238. });
  239. $('#showtoast').click(function () {
  240. var shortCutFunction = $("#toastTypeGroup input:radio:checked").val();
  241. var msg = $('#message').val();
  242. var title = $('#title').val() || '';
  243. var $showDuration = $('#showDuration');
  244. var $hideDuration = $('#hideDuration');
  245. var $timeOut = $('#timeOut');
  246. var $extendedTimeOut = $('#extendedTimeOut');
  247. var $showEasing = $('#showEasing');
  248. var $hideEasing = $('#hideEasing');
  249. var $showMethod = $('#showMethod');
  250. var $hideMethod = $('#hideMethod');
  251. var toastIndex = toastCount++;
  252. toastr.options = {
  253. closeButton: $('#closeButton').prop('checked'),
  254. debug: $('#debugInfo').prop('checked'),
  255. progressBar: $('#progressBar').prop('checked'),
  256. positionClass: $('#positionGroup input:radio:checked').val() || 'toast-top-right',
  257. onclick: null
  258. };
  259. if ($('#addBehaviorOnToastClick').prop('checked')) {
  260. toastr.options.onclick = function () {
  261. alert('You can perform some custom action after a toast goes away');
  262. };
  263. }
  264. if ($showDuration.val().length) {
  265. toastr.options.showDuration = $showDuration.val();
  266. }
  267. if ($hideDuration.val().length) {
  268. toastr.options.hideDuration = $hideDuration.val();
  269. }
  270. if ($timeOut.val().length) {
  271. toastr.options.timeOut = $timeOut.val();
  272. }
  273. if ($extendedTimeOut.val().length) {
  274. toastr.options.extendedTimeOut = $extendedTimeOut.val();
  275. }
  276. if ($showEasing.val().length) {
  277. toastr.options.showEasing = $showEasing.val();
  278. }
  279. if ($hideEasing.val().length) {
  280. toastr.options.hideEasing = $hideEasing.val();
  281. }
  282. if ($showMethod.val().length) {
  283. toastr.options.showMethod = $showMethod.val();
  284. }
  285. if ($hideMethod.val().length) {
  286. toastr.options.hideMethod = $hideMethod.val();
  287. }
  288. if (!msg) {
  289. msg = getMessage();
  290. }
  291. $("#toastrOptions").text("Command: toastr[" + shortCutFunction + "](\"" + msg + (title ? "\", \"" + title : '') + "\")\n\ntoastr.options = " + JSON.stringify(toastr.options, null, 2));
  292. var $toast = toastr[shortCutFunction](msg, title); // Wire up an event handler to a button in the toast, if it exists
  293. $toastlast = $toast;
  294. if ($toast.find('#okBtn').length) {
  295. $toast.delegate('#okBtn', 'click', function () {
  296. alert('you clicked me. i was toast #' + toastIndex + '. goodbye!');
  297. $toast.remove();
  298. });
  299. }
  300. if ($toast.find('#surpriseBtn').length) {
  301. $toast.delegate('#surpriseBtn', 'click', function () {
  302. alert('Surprise! you clicked me. i was toast #' + toastIndex + '. You could perform an action here.');
  303. });
  304. }
  305. });
  306. function getLastToast() {
  307. return $toastlast;
  308. }
  309. $('#clearlasttoast').click(function () {
  310. toastr.clear(getLastToast());
  311. });
  312. $('#cleartoasts').click(function () {
  313. toastr.clear();
  314. });
  315. })
  316. </script>
  317. <script type="text/javascript" src="http://tajs.qq.com/stats?sId=9051096" charset="UTF-8"></script>
  318. <!--统计代码,可删除-->
  319. </body>
  320. </html>