From 37332ae2222706f8fb330dae780dc938512edcf5 Mon Sep 17 00:00:00 2001 From: Frédéric Guillot Date: Sun, 2 Nov 2014 15:06:41 -0500 Subject: Change layout (experimental) --- assets/js/base.js | 81 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 assets/js/base.js (limited to 'assets/js/base.js') diff --git a/assets/js/base.js b/assets/js/base.js new file mode 100644 index 00000000..55a8fd1e --- /dev/null +++ b/assets/js/base.js @@ -0,0 +1,81 @@ +// Common functions +var Kanboard = (function() { + + return { + + // Display a popup + Popover: function(e, callback) { + e.preventDefault(); + e.stopPropagation(); + + var link = e.target.getAttribute("href"); + + if (! link) { + link = e.target.getAttribute("data-href"); + } + + if (link) { + $.get(link, function(content) { + + $("body").append('
' + content + '
'); + + $("#popover-container").click(function() { + $(this).remove(); + }); + + $("#popover-content").click(function(e) { + e.stopPropagation(); + }); + + if (callback) { + callback(); + } + }); + } + }, + + // Return true if the page is visible + IsVisible: function() { + + var property = ""; + + if (typeof document.hidden !== "undefined") { + property = "visibilityState"; + } else if (typeof document.mozHidden !== "undefined") { + property = "mozVisibilityState"; + } else if (typeof document.msHidden !== "undefined") { + property = "msVisibilityState"; + } else if (typeof document.webkitHidden !== "undefined") { + property = "webkitVisibilityState"; + } + + if (property != "") { + return document[property] == "visible"; + } + + return true; + }, + + // Common init + Init: function() { + + // Datepicker + $(".form-date").datepicker({ + showOtherMonths: true, + selectOtherMonths: true, + dateFormat: 'yy-mm-dd', + constrainInput: false + }); + + // Project select box + $("#board-selector").chosen({ + width: 180 + }); + + $("#board-selector").change(function() { + window.location = "?controller=board&action=show&project_id=" + $(this).val(); + }); + } + }; + +})(); \ No newline at end of file -- cgit v1.2.3