Sha256: bb7121c6bac99828de2e7d28479e92d648cc8bc106ec275f010a9f1d1215c216

Contents?: true

Size: 1.62 KB

Versions: 1

Compression:

Stored size: 1.62 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.0 lib/assets/javascripts/outpost/publishing.js.coffee