### # @description This module is used to generate HTML-Code. # @copyright 2014 by Tobias Reich ### window.build = {} build.iconic = (icon, classes, path) -> path = path || 'src/images/iconic.svg' classes = classes || 'iconic' "" build.divider = (title) -> "

#{ title }

" build.editIcon = (id) -> "
" build.multiselect = (top, left) -> "
" build.album = (data) -> return '' if not data? title = data.title longTitle = '' typeThumb = '' if title? and title.length > 18 title = data.title.substr(0, 18) + '...' longTitle = data.title if data.thumb0.split('.').pop() is 'svg' then typeThumb = 'nonretina' html = """
thumb thumb thumb
""" if data.password and lychee.publicMode is false html += "

#{ title }

"; else html += "

#{ title }

" html += """ #{ data.sysdate }
""" if lychee.publicMode is false if data.star is '1' then html += "" if data.public is '1' then html += "" if data.unsorted is '1' then html += "" if data.recent is '1' then html += "" html += "
" return html build.photo = (data) -> return '' if not data? title = data.title longTitle = '' if title? and title.length > 18 title = data.title.substr(0, 18) + '...' longTitle = data.title html = """
thumb

#{ title }

""" if data.cameraDate is '1' html += "#{ data.sysdate }" else html += "#{ data.sysdate }" html += "
" if data.star is '1' then html += "" if lychee.publicMode is false and data.public is '1' and album.json.public isnt '1' then html += "" html += "
" return html build.imageview = (data, size, visibleControls) -> return '' if not data? html = """ """ if size is 'big' if visibleControls is true html += "
" else html += "
" else if size is 'medium' if visibleControls is true html += "
" else html += "
" else if size is 'small' if visibleControls is true html += "
" else html += "
" return html build.no_content = (typ) -> html = """
""" switch typ when 'search' then html += "

No results

" when 'share' then html += "

No public albums

" when 'cog' then html += "

No configuration

" html += "
" return html build.modal = (title, text, button, marginTop, closeButton) -> if marginTop? then custom_style = "style='margin-top: #{ marginTop }px;'" else custom_style = '' html = """

#{ title }

""" if closeButton isnt false then html += "" html += "

#{ text }

" $.each button, (index) -> if this[0] isnt '' if index is 0 then html += "#{ this[0] }" else html += "#{ this[0] }" html += """
""" return html build.signInModal = -> html = """

Sign In

Version #{ lychee.version }Update available!
Sign in
""" return html build.uploadModal = (title, files) -> html = """

#{ title }

""" i = 0 file = null while i < files.length file = files[i] if file.name.length > 40 file.name = file.name.substr(0, 17) + '...' + file.name.substr(file.name.length-20, 20) html += """
#{ lychee.escapeHTML(file.name) } """ if file.supported is true then html += "" else html += "Not supported" html += """

""" i++ html += """
""" return html build.tags = (tags, forView) -> html = '' if forView is true or lychee.publicMode is true then editTagsHTML = '' else editTagsHTML = ' ' + build.editIcon('edit_tags') if tags isnt '' tags = tags.split ',' tags.forEach (tag, index, array) -> html += "#{ tag }" html += editTagsHTML else html = "
No Tags#{ editTagsHTML }
" return html build.infoboxPhoto = (data, forView) -> html = """

About

#{ build.iconic('circle-x') }
""" switch data.public when '0' then visible = 'No' when '1' then visible = 'Yes' when '2' then visible = 'Yes (Album)' else visible = '-' if forView is true or lychee.publicMode is true then editTitleHTML = '' else editTitleHTML = ' ' + build.editIcon('edit_title') if forView is true or lychee.publicMode is true then editDescriptionHTML = '' else editDescriptionHTML = ' ' + build.editIcon('edit_description') infos = [ ['', 'Basics'] ['Title', data.title + editTitleHTML] ['Uploaded', data.sysdate] ['Description', data.description + editDescriptionHTML] ['', 'Image'] ['Size', data.size] ['Format', data.type] ['Resolution', data.width + ' x ' + data.height] ['Tags', build.tags(data.tags, forView)] ] exifHash = data.takestamp+data.make+data.model+data.shutter+data.aperture+data.focal+data.iso if exifHash isnt '0' or exifHash isnt '0' infos = infos.concat [ ['', 'Camera'] ['Captured', data.takedate] ['Make', data.make] ['Type/Model', data.model] ['Shutter Speed', data.shutter] ['Aperture', data.aperture] ['Focal Length', data.focal] ['ISO', data.iso] ] infos = infos.concat [ ['', 'Share'] ['Public', visible] ] infos.forEach (info, i, items) -> if info[1] is '' or not info[1]? info[1] = '-' switch info[0] when '' # Separator html += """

#{ info[1] }

""" when 'Tags' # Tags if forView isnt true and lychee.publicMode is false html += """

#{ info[0] }

#{ info[1] }
""" else # Item html += """ #{ info[0] } #{ info[1] } """ html += """
""" return html build.infoboxAlbum = (data, forView) -> html = """

About

#{ build.iconic('circle-x') }
""" switch data.public when '0' then visible = 'No' when '1' then visible = 'Yes' else visible = '-' switch data.password when false then password = 'No' when true then password = 'Yes' else password = '-' switch data.downloadable when '0' then downloadable = 'No' when '1' then downloadable = 'Yes' else downloadable = '-' if forView is true or lychee.publicMode is true then editTitleHTML = '' else editTitleHTML = ' ' + build.editIcon('edit_title_album') if forView is true or lychee.publicMode is true then editDescriptionHTML = '' else editDescriptionHTML = ' ' + build.editIcon('edit_description_album') infos = [ ['', 'Basics'] ['Title', data.title + editTitleHTML] ['Description', data.description + editDescriptionHTML] ['', 'Album'] ['Created', data.sysdate] ['Images', data.num] ['', 'Share'] ['Public', visible] ['Downloadable', downloadable] ['Password', password] ] infos.forEach (info, i, items) -> if info[0] is '' # Separator html += """

#{ info[1] }

""" else # Item html += """ """ html += """
#{ info[0] } #{ info[1] }
""" return html