|
1 | | -window.djdt = (function(window, document, $) { |
2 | | - $.cookie = function(name, value, options) { if (typeof value != 'undefined') { options = options || {}; if (value === null) { value = ''; options.expires = -1; } var expires = ''; if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) { var date; if (typeof options.expires == 'number') { date = new Date(); date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000)); } else { date = options.expires; } expires = '; expires=' + date.toUTCString(); } var path = options.path ? '; path=' + (options.path) : ''; var domain = options.domain ? '; domain=' + (options.domain) : ''; var secure = options.secure ? '; secure' : ''; document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join(''); } else { var cookieValue = null; if (document.cookie && document.cookie != '') { var cookies = document.cookie.split(';'); for (var i = 0; i < cookies.length; i++) { var cookie = $.trim(cookies[i]); if (cookie.substring(0, name.length + 1) == (name + '=')) { cookieValue = decodeURIComponent(cookie.substring(name.length + 1)); break; } } } return cookieValue; } }; |
| 1 | +window.djdt = (function(window, document, jQuery) { |
| 2 | + jQuery.cookie = function(name, value, options) { if (typeof value != 'undefined') { options = options || {}; if (value === null) { value = ''; options.expires = -1; } var expires = ''; if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) { var date; if (typeof options.expires == 'number') { date = new Date(); date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000)); } else { date = options.expires; } expires = '; expires=' + date.toUTCString(); } var path = options.path ? '; path=' + (options.path) : ''; var domain = options.domain ? '; domain=' + (options.domain) : ''; var secure = options.secure ? '; secure' : ''; document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join(''); } else { var cookieValue = null; if (document.cookie && document.cookie != '') { var cookies = document.cookie.split(';'); for (var i = 0; i < cookies.length; i++) { var cookie = $.trim(cookies[i]); if (cookie.substring(0, name.length + 1) == (name + '=')) { cookieValue = decodeURIComponent(cookie.substring(name.length + 1)); break; } } } return cookieValue; } }; |
| 3 | + var $ = jQuery; |
3 | 4 | var COOKIE_NAME = 'djdt'; |
4 | 5 | var djdt = { |
| 6 | + jQuery: jQuery, |
| 7 | + events: { |
| 8 | + ready: [] |
| 9 | + }, |
5 | 10 | init: function() { |
6 | 11 | $('#djDebug').show(); |
7 | 12 | var current = null; |
@@ -80,6 +85,9 @@ window.djdt = (function(window, document, $) { |
80 | 85 | }, function(){ |
81 | 86 | $(this).removeClass('djDebugHover'); |
82 | 87 | }); |
| 88 | + $.each(djdt.events.ready, function(_, callback){ |
| 89 | + callback(djdt); |
| 90 | + }); |
83 | 91 | }, |
84 | 92 | toggle_content: function(elem) { |
85 | 93 | if (elem.is(':visible')) { |
@@ -132,6 +140,9 @@ window.djdt = (function(window, document, $) { |
132 | 140 | var uarr = String.fromCharCode(0x25b6); |
133 | 141 | var darr = String.fromCharCode(0x25bc); |
134 | 142 | elem.html(elem.html() == uarr ? darr : uarr); |
| 143 | + }, |
| 144 | + ready: function(callback){ |
| 145 | + djdt.events.ready.push(callback); |
135 | 146 | } |
136 | 147 | }; |
137 | 148 | $(document).ready(function() { |
|
0 commit comments