<commit_before>class KDView extends KDObject

# #
# CLASS LEVEL STUFF
# #

  {defineProperty} = Object

  deprecated = (methodName)-> warn "#{methodName} is deprecated from KDView if you need it override in your subclass"

  eventNames =
    ///
    ^(
    (dbl)?click|
    key(up|down|press)|
    mouse(up|down|over|enter|leave|move)|
    drag(start|end|enter|leave|over)|
    blur|change|focus|
    drop|
    contextmenu|
    scroll|
    paste|
    error
    )$
    ///

  overrideAndMergeObjects = (objects)->
    for own title,item of objects.overridden
      continue if objects.overrider[title]
      objects.overrider[title] = item
    objects.overrider

  @appendToDOMBody = (view)->
    $("body").append view.$()
    view.parentIsInDom = yes
    view.propagateEvent KDEventType: 'viewAppended'

# #
# INSTANCE LEVEL
# #

  constructor:(options = {},data)->

    o = options
    o.tagName     or= "div"     # a String of a HTML tag
    o.domId       or= null      # a String
    o.cssClass    or= ""        # a String
    o.parent      or= null      # a KDView Instance
    o.partial     or= null      # a String of HTML or text
    o.pistachio   or= null      # a String of Pistachio
    o.delegate    or= null      # a KDView Instance
    o.bind        or= ""        # a String of space seperated javascript dom events to be listened on instantiated view
    o.draggable   or= null      # an Object holding draggable options and/or events !!! NOT HTML5 !!!
    o.droppable   or= null      # TBDL
    o.size        or= null      # an Object holding width and height properties
    o.position    or= null      # an Object holding top/right/bottom/left properties (would force view to be positioned absolutely)
    o.attributes  or= null      # an Object holding attribute key/value pairs e.g. {href:'#',title:'my picture'}
    o.prefix      or= ""        # a String
    o.suffix      or= ""        # a String
    o.tooltip     or= null      # an Object of twipsy options
    # TO BE IMPLEMENTED
    o.resizable   or= null      # TBDL
    super o,data

    data?.on? 'update', =>
      data
      @render()

    @setInstanceVariables options
    @defaultInit options,data

    if location.hostname is 'localhost'
      @listenTo
        KDEventTypes        : 'click'
        listenedToInstance  : @
        callback            : (publishingInstance, event)=>
          if event.metaKey and event.altKey and event.ctrlKey
            log @getData()
            event.stopPropagation?()
            event.preventDefault?()
            return false
          else if event.ctrlKey and event.altKey
            log @
            return false

    @listenTo
      KDEventTypes        : 'childAppended'
      listenedToInstance  : @
      callback            : (publishingInstance, child)=>
        @childAppended child

    @listenTo
      KDEventTypes        : 'viewAppended'
      listenedToInstance  : @
      callback            : =>
        @setViewReady()
        @viewAppended()
        @childAppended @<commit_msg>bottom panel minor, (meta|ctrl)+alt click logs the view<commit_after>class KDView extends KDObject

# #
# CLASS LEVEL STUFF
# #

  {defineProperty} = Object

  deprecated = (methodName)-> warn "#{methodName} is deprecated from KDView if you need it override in your subclass"

  eventNames =
    ///
    ^(
    (dbl)?click|
    key(up|down|press)|
    mouse(up|down|over|enter|leave|move)|
    drag(start|end|enter|leave|over)|
    blur|change|focus|
    drop|
    contextmenu|
    scroll|
    paste|
    error
    )$
    ///

  overrideAndMergeObjects = (objects)->
    for own title,item of objects.overridden
      continue if objects.overrider[title]
      objects.overrider[title] = item
    objects.overrider

  @appendToDOMBody = (view)->
    $("body").append view.$()
    view.parentIsInDom = yes
    view.propagateEvent KDEventType: 'viewAppended'

# #
# INSTANCE LEVEL
# #

  constructor:(options = {},data)->

    o = options
    o.tagName     or= "div"     # a String of a HTML tag
    o.domId       or= null      # a String
    o.cssClass    or= ""        # a String
    o.parent      or= null      # a KDView Instance
    o.partial     or= null      # a String of HTML or text
    o.pistachio   or= null      # a String of Pistachio
    o.delegate    or= null      # a KDView Instance
    o.bind        or= ""        # a String of space seperated javascript dom events to be listened on instantiated view
    o.draggable   or= null      # an Object holding draggable options and/or events !!! NOT HTML5 !!!
    o.droppable   or= null      # TBDL
    o.size        or= null      # an Object holding width and height properties
    o.position    or= null      # an Object holding top/right/bottom/left properties (would force view to be positioned absolutely)
    o.attributes  or= null      # an Object holding attribute key/value pairs e.g. {href:'#',title:'my picture'}
    o.prefix      or= ""        # a String
    o.suffix      or= ""        # a String
    o.tooltip     or= null      # an Object of twipsy options
    # TO BE IMPLEMENTED
    o.resizable   or= null      # TBDL
    super o,data

    data?.on? 'update', =>
      data
      @render()

    @setInstanceVariables options
    @defaultInit options,data

    if location.hostname is 'localhost'
      @listenTo
        KDEventTypes        : 'click'
        listenedToInstance  : @
        callback            : (publishingInstance, event)=>
          if event.metaKey and event.altKey and event.ctrlKey
            log @getData()
            event.stopPropagation?()
            event.preventDefault?()
            return false
          else if event.altKey and (event.metaKey or event.ctrlKey)
            log @
            return false

    @listenTo
      KDEventTypes        : 'childAppended'
      listenedToInstance  : @
      callback            : (publishingInstance, child)=>
        @childAppended child

    @listenTo
      KDEventTypes        : 'viewAppended'
      listenedToInstance  : @
      callback            : =>
        @setViewReady()
        @viewAppended()
        @childAppended @
{'fraction_non_alphanumeric': 0.09265018824684891, 'fraction_numerical': 0.0003273858241938124, 'mean_word_length': 2.017283950617284, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4181676', 'n_tokens_mistral': 1839, 'n_tokens_neox': 1794, 'n_words': 529}