Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
424 changed files
with
22,430 additions
and
260 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
Gws_Affair_Menu = function (current, sessionKey) { | ||
this.current = current; | ||
this.sessionKey = sessionKey; | ||
this.render(); | ||
}; | ||
|
||
Gws_Affair_Menu.prototype.render = function() { | ||
var self = this; | ||
this.initNarrow(); | ||
$(".toggle-narrow-page").on("click", function(){ | ||
var $a = $(this); | ||
var $h3 = $a.closest("h3"); | ||
var $narrow = $h3.next(".narrow-page"); | ||
|
||
if ($narrow.hasClass("show")) { | ||
self.hideNarrow($narrow, "fast"); | ||
$a.removeClass("down"); | ||
self.updateSession(); | ||
} else { | ||
self.showNarrow($narrow, "fast"); | ||
$a.addClass("down"); | ||
self.updateSession(); | ||
} | ||
return false; | ||
}); | ||
}; | ||
|
||
Gws_Affair_Menu.prototype.showNarrow = function(ele, duration) { | ||
$(ele).removeClass("hide"); | ||
$(ele).addClass("show"); | ||
$(ele).show(duration); | ||
}; | ||
|
||
Gws_Affair_Menu.prototype.hideNarrow = function(ele, duration) { | ||
$(ele).removeClass("show"); | ||
$(ele).hide(duration, function(){ | ||
$(this).addClass("hide"); | ||
}); | ||
}; | ||
|
||
Gws_Affair_Menu.prototype.getSession = function() { | ||
var navi = sessionStorage.getItem(this.sessionKey); | ||
if (navi) { | ||
navi = navi.split(",") | ||
} else { | ||
navi = []; | ||
} | ||
return navi; | ||
}; | ||
|
||
Gws_Affair_Menu.prototype.updateSession = function() { | ||
var navi = $(".narrow-page[data-navi].show").map(function() { return $(this).attr("data-navi") }).toArray(); | ||
sessionStorage.setItem(this.sessionKey, navi.join(",")); | ||
}; | ||
|
||
Gws_Affair_Menu.prototype.initNarrow = function () { | ||
var self = this; | ||
$(".toggle-narrow-page").each(function(){ | ||
var $a = $(this); | ||
var $h3 = $a.closest("h3"); | ||
var $narrow = $h3.next(".narrow-page"); | ||
|
||
var navi = self.getSession(); | ||
var content = $narrow.attr("data-navi"); | ||
|
||
if (navi.includes(content) || content == "<%= current_navi %>") { | ||
self.showNarrow($narrow); | ||
$a.addClass("down"); | ||
} else { | ||
self.hideNarrow($narrow); | ||
$a.removeClass("down"); | ||
} | ||
}); | ||
self.updateSession(); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
Gws_Affair_ShiftRecords = function (el, options) { | ||
this.el = el; | ||
this.$el = $(el); | ||
this.$toolbar = this.$el.find('.cell-toolbar'); | ||
this.options = options; | ||
this.render(); | ||
}; | ||
|
||
Gws_Affair_ShiftRecords.prototype.render = function() { | ||
var _this = this; | ||
|
||
$(document).on('click', this.el + ' .shift-record', function(ev) { | ||
ev.preventDefault(); | ||
ev.stopPropagation(); | ||
_this.onClickCell($(this)); | ||
}); | ||
|
||
$(this.el).find(".wrap-table").scroll(function () { | ||
_this.$toolbar.hide(); | ||
}); | ||
|
||
_this.$toolbar.hide(); | ||
}; | ||
|
||
Gws_Affair_ShiftRecords.prototype.setFocus = function($cell) { | ||
this.$el.find('.shift-record').removeClass('focus'); | ||
$cell.addClass('focus'); | ||
}; | ||
|
||
Gws_Affair_ShiftRecords.prototype.onClickCell = function($cell) { | ||
this.setFocus($cell); | ||
|
||
var day = $cell.data('day'); | ||
var user = $cell.data('user'); | ||
|
||
var showsToolbar = false; | ||
var editable = this.options.editable; | ||
if (editable) { | ||
var url = this.options.shiftRecordUrl; | ||
url = url.replace(':day', day); | ||
url = url.replace(':user', user); | ||
|
||
showsToolbar = true; | ||
this.$toolbar.find('.edit').attr('href', url).show(); | ||
} | ||
|
||
if (! showsToolbar) { | ||
this.$toolbar.hide(); | ||
return; | ||
} | ||
|
||
var offset = $cell.offset(); | ||
if ($cell.hasClass('top')) { | ||
offset.top -= this.$toolbar.outerHeight(); | ||
} else { | ||
offset.top += $cell.outerHeight(); | ||
} | ||
|
||
// call `show` and then call `offset`. order is important | ||
this.$toolbar.show(); | ||
this.$toolbar.offset(offset); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.