Sha256: 18238d9eb4a1744159ba30968438e40780b4e21977b7d76c7a811a12ae06a842

Contents?: true

Size: 1.56 KB

Versions: 1

Compression:

Stored size: 1.56 KB

Contents

#= require outpost/publishing_helper

##
# PublishingUI
#
# Show/hide Publishing fields based on status.
# Also renders messages based on status
#
class outpost.Publishing extends outpost.PublishingHelper
    constructor: (@options={}) ->
        super

        # Alerts
        @alerts =
            willPublish:    new outpost.Notification(@notifications, "warning", "This content <strong>will be published</strong> immediately.")
            isPublished:    new outpost.Notification(@notifications, "success", "This content is <strong>published</strong>")
            willUnpublish:  new outpost.Notification(@notifications, "danger", "<strong>Warning!</strong> This content <strong>will be unpublished</strong> immediately.")

        # Notify the scheduled status
        @originalStatus = @setStatus() # also sets @status
        @hideFields() # Hidden by default.
        @notify()

    #----------

    notify: ->
        @clearAlerts()

        # No need to run these methods more than once
        isPublished = @isPublished()
        wasPublished = @wasPublished()

        # Show the fields if it's published.
        @showFields() if isPublished

        # All the different scenarios
        # Already published
        if isPublished and wasPublished
            @showFields()
            return @alert 'isPublished'

        # Publishing
        if isPublished and !wasPublished
            @hideFields()
            return @alert 'willPublish'

        # Unpublishing
        if !isPublished and wasPublished
            @hideFields()
            return @alert 'willUnpublish'

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
outpost-publishing-1.0.1 lib/assets/javascripts/outpost/publishing.js.coffee