0
0
Fork 0
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:
Alexander Yakovlev 2016-09-19 22:15:16 +07:00
parent 23e2be646f
commit a1a1469c51
2 changed files with 22 additions and 17 deletions

View file

@ -31,7 +31,7 @@ task 'build', 'Compile all CoffeeScript files', ->
util.log err util.log err
process.exit 1 # abort npm packaging process.exit 1 # abort npm packaging
util.log "Compiled CoffeeScript." 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 if err
util.log err util.log err
process.exit 1 # abort npm packaging process.exit 1 # abort npm packaging

View file

@ -51,7 +51,7 @@ class SaletView
# Scrolls the top of the screen to the specified point # Scrolls the top of the screen to the specified point
scrollTopTo: (value) -> 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 # Scrolls the bottom of the screen to the specified point
scrollBottomTo: (value) -> scrollBottomTo: (value) ->
@ -145,7 +145,7 @@ class SaletView
currentRoom = salet.getCurrentRoom() currentRoom = salet.getCurrentRoom()
$options = jQuery("<ul>").addClass("options") $options = jQuery("<ul>").addClass("options")
for roomId in listOfIds for roomId, i in listOfIds
room = salet.rooms[roomId] room = salet.rooms[roomId]
assert(room, "unknown_situation".l({id:roomId})) assert(room, "unknown_situation".l({id:roomId}))
if (room == currentRoom) if (room == currentRoom)
@ -171,22 +171,27 @@ class SaletView
# Arguments: # Arguments:
# interactive - if we're working in interactive mode (or we're loading a save) # interactive - if we're working in interactive mode (or we're loading a save)
removeTransient: (interactive = false) -> 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') for a in jQuery('#content').find('a')
a = jQuery(a) a = jQuery(a)
if (a.hasClass('sticky') || a.attr("href").match(/[?&]sticky[=&]?/)) if (a.hasClass('sticky') || a.attr("href").match(/[?&]sticky[=&]?/))
return return
a.replaceWith(jQuery("<span>").addClass("ex_link").html(a.html())) 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. # At last, we scroll the view so that .new objects are in view.
endOutputTransaction: () => endOutputTransaction: () =>
@ -213,16 +218,16 @@ class SaletView
# The new content is too long for our viewport, so we scroll the # 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 # top of the new content to roughly 75% of the way up the viewport's
# height. # height.
scrollTopTo(newTop-(viewHeight*0.25) - optionHeight); @scrollTopTo(newTop-(viewHeight*0.25) - optionHeight);
else else
if (newTop > jQuery('body').height() - viewHeight) if (newTop > jQuery('body').height() - viewHeight)
# If we scroll right to the bottom, the new content will be in # If we scroll right to the bottom, the new content will be in
# view. So we do that. # view. So we do that.
scrollToBottom(); @scrollToBottom()
else else
# Our new content is too far up the page. So we scroll to place # Our new content is too far up the page. So we scroll to place
# it somewhere near the bottom. # it somewhere near the bottom.
scrollBottomTo(newBottom+100 - optionHeight); @scrollBottomTo(newBottom+100 - optionHeight)
# Feature detection # Feature detection
hasLocalStorage: () -> hasLocalStorage: () ->