summaryrefslogtreecommitdiff
path: root/assets/js/base.js
diff options
context:
space:
mode:
authorFrédéric Guillot <fred@kanboard.net>2014-11-02 15:06:41 -0500
committerFrédéric Guillot <fred@kanboard.net>2014-11-02 15:06:41 -0500
commit37332ae2222706f8fb330dae780dc938512edcf5 (patch)
tree9161d539cc289179339162d6922c4d9dd2c30e63 /assets/js/base.js
parent8fe5df39d97ef851d11931fcf7e906ec08838ef7 (diff)
Change layout (experimental)
Diffstat (limited to 'assets/js/base.js')
-rw-r--r--assets/js/base.js81
1 files changed, 81 insertions, 0 deletions
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('<div id="popover-container"><div id="popover-content">' + content + '</div></div>');
+
+ $("#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