mirror of
https://gitlab.com/Oreolek/salet-module.git
synced 2024-06-28 21:05:03 +03:00
Many fixes
- No querying scroll animations anymore - The module is minified into ES5 now - Fixed the transient Markdown-style links (see undum) - Fixed the scrolling - The choices in writeChoices() now correctly get the index to l() localizing function
This commit is contained in:
parent
23e2be646f
commit
a1a1469c51
2
Cakefile
2
Cakefile
|
@ -31,7 +31,7 @@ task 'build', 'Compile all CoffeeScript files', ->
|
|||
util.log err
|
||||
process.exit 1 # abort npm packaging
|
||||
util.log "Compiled CoffeeScript."
|
||||
exec "closure-compiler --js_output_file lib/index.min.js lib/index.js", (err) ->
|
||||
exec "closure-compiler --compilation_level ECMASCRIPT5 --compilation_level SIMPLE --js_output_file lib/index.min.js lib/index.js", (err) ->
|
||||
if err
|
||||
util.log err
|
||||
process.exit 1 # abort npm packaging
|
||||
|
|
|
@ -51,7 +51,7 @@ class SaletView
|
|||
|
||||
# Scrolls the top of the screen to the specified point
|
||||
scrollTopTo: (value) ->
|
||||
jQuery('html,body').animate({scrollTop: value}, 500)
|
||||
jQuery('html,body').stop().animate({scrollTop: value}, 500)
|
||||
|
||||
# Scrolls the bottom of the screen to the specified point
|
||||
scrollBottomTo: (value) ->
|
||||
|
@ -145,7 +145,7 @@ class SaletView
|
|||
|
||||
currentRoom = salet.getCurrentRoom()
|
||||
$options = jQuery("<ul>").addClass("options")
|
||||
for roomId in listOfIds
|
||||
for roomId, i in listOfIds
|
||||
room = salet.rooms[roomId]
|
||||
assert(room, "unknown_situation".l({id:roomId}))
|
||||
if (room == currentRoom)
|
||||
|
@ -171,22 +171,27 @@ class SaletView
|
|||
# Arguments:
|
||||
# interactive - if we're working in interactive mode (or we're loading a save)
|
||||
removeTransient: (interactive = false) ->
|
||||
contentToHide = jQuery('#content .transient')
|
||||
contentToHide.add(jQuery('#content .options'))
|
||||
contentToHide.add(jQuery("#content a").filter(() ->
|
||||
return jQuery(this).attr("href").match(/[?&]transient[=&]?/)
|
||||
))
|
||||
if (interactive)
|
||||
contentToHide.animate({
|
||||
opacity: 0,
|
||||
height: 0
|
||||
}, {
|
||||
duration: 500,
|
||||
always: () ->
|
||||
jQuery(this).remove()
|
||||
})
|
||||
else
|
||||
contentToHide.remove()
|
||||
for a in jQuery('#content').find('a')
|
||||
a = jQuery(a)
|
||||
if (a.hasClass('sticky') || a.attr("href").match(/[?&]sticky[=&]?/))
|
||||
return
|
||||
a.replaceWith(jQuery("<span>").addClass("ex_link").html(a.html()))
|
||||
contentToHide = jQuery('#content .transient, #content ul.options')
|
||||
contentToHide.add(jQuery("#content a").filter(() ->
|
||||
return jQuery(this).attr("href").match(/[?&]transient[=&]?/)
|
||||
))
|
||||
if (interactive)
|
||||
contentToHide.animate({opacity: 0}, 350).
|
||||
slideUp(500, () ->
|
||||
jQuery(this).remove()
|
||||
)
|
||||
else
|
||||
contentToHide.remove()
|
||||
|
||||
# At last, we scroll the view so that .new objects are in view.
|
||||
endOutputTransaction: () =>
|
||||
|
@ -213,16 +218,16 @@ class SaletView
|
|||
# The new content is too long for our viewport, so we scroll the
|
||||
# top of the new content to roughly 75% of the way up the viewport's
|
||||
# height.
|
||||
scrollTopTo(newTop-(viewHeight*0.25) - optionHeight);
|
||||
@scrollTopTo(newTop-(viewHeight*0.25) - optionHeight);
|
||||
else
|
||||
if (newTop > jQuery('body').height() - viewHeight)
|
||||
# If we scroll right to the bottom, the new content will be in
|
||||
# view. So we do that.
|
||||
scrollToBottom();
|
||||
@scrollToBottom()
|
||||
else
|
||||
# Our new content is too far up the page. So we scroll to place
|
||||
# it somewhere near the bottom.
|
||||
scrollBottomTo(newBottom+100 - optionHeight);
|
||||
@scrollBottomTo(newBottom+100 - optionHeight)
|
||||
|
||||
# Feature detection
|
||||
hasLocalStorage: () ->
|
||||
|
|
Loading…
Reference in a new issue