<commit_before>// ========================================================================
// SproutCore
// copyright 2006-2008 Sprout Systems, Inc.
// ========================================================================

require('views/view') ;

/** @class

  Used to display an iframe.
  
  
  @extends SC.View
  @since SproutCore 1.0
*/
SC.IFrameView = SC.View.extend({
  
  emptyElement: '<div><iframe style="position: absolute; width: 100%; height: 100%; border: 0px; margin: 0px; padding: 0p;"></iframe></div>',
  styleClass: 'sc-iframe-view',

  content: null,
  contentBindingDefault: SC.Binding.single().notEmpty(),
  
  contentUrlKey: null,
  contentUrlKeyBindingDefault: SC.Binding.single(),
  
  displayProperties: ['content'],

  updateDisplay: function() {
    var content = this.get('content') ;
    var urlKey = this.get('contentUrlKey') ;
    var src = '';
    
    console.log(content);
  
    switch (content) {
      case SC.MULTIPLE_PLACEHOLDER:
      case SC.EMPTY_PLACEHOLDER:
      case SC.NULL_PLACEHOLDER:
        src = static_url('blank');
        break;
      default:
        src = (urlKey) ? content.get(urlKey) : content ;
        break;
    }
    
    console.log(src) ;
    
    this.$('iframe').attr('src', src) ;      
  },

  /** @private */
  _contentDidChange: function(target,key,value,propertyRevision) {
    // handle changes to the content...
    if ((value = this.get('content')) != this._field_content) {

      // get the handler method
      var f = this._contentPropertyDidChange ;
      
      // stop listening to old content.
      if (this._field_content) {
        if (SC.isArray(this._field_content)) {
          this._field_content.invoke('removeObserver', '*', this, f) ;
        } else if (this._field_content.removeObserver) {
          this._field_content.removeObserver('*', this, f) ;
        }
      }
      
      // start listening for changes on the new content object.
      this._field_content = value ;
      if (value) {
        if (SC.isArray(value)) {
          value.invoke('addObserver', '*', this, f) ;
        } else if (value.addObserver) {
          value.addObserver('*', this, f) ;
        }
      }

      // notify everyone that everything is different now.<commit_msg>add delegate API to SC.IFrameView<commit_after>// ========================================================================
// SproutCore
// copyright 2006-2008 Sprout Systems, Inc.
// ========================================================================

require('views/view') ;

/** @class

  Used to display an iframe.
  
  
  @extends SC.View
  @since SproutCore 1.0
*/
SC.IFrameView = SC.View.extend({
  
  emptyElement: '<div><iframe style="position: absolute; width: 100%; height: 100%; border: 0px; margin: 0px; padding: 0p;"></iframe></div>',
  styleClass: 'sc-iframe-view',

  content: null,
  contentBindingDefault: SC.Binding.single().notEmpty(),
  
  contentUrlKey: null,
  contentUrlKeyBindingDefault: SC.Binding.single(),
  
  displayProperties: ['content'],
  
  $iframe: function() { return this.$('iframe') ; },
  
  delegate: null,
  
  iFrameViewWillLoadUrl: function(view, url) { return url; },
  iFrameViewDidLoadUrl: function(view, url) {},
  
  updateDisplay: function() {
    var content = this.get('content') ;
    var urlKey = this.get('contentUrlKey') ;
    var src = '';
    
    switch (content) {
      case SC.MULTIPLE_PLACEHOLDER:
      case SC.EMPTY_PLACEHOLDER:
      case SC.NULL_PLACEHOLDER:
        src = static_url('blank');
        break;
      default:
        src = (urlKey) ? content.get(urlKey) : content ;
        break;
    }
    
    src = this.invokeDelegateMethod(this.delegate, 'iFrameViewWillLoadUrl', this, src) || '' ;
    var iframe = this.$iframe() ;
    iframe.attr('src', 'javascript:;') ; // clear out the previous src, to force a reload
    iframe.attr('src', src) ;
    this.invokeDelegateMethod(this.delegate, 'iFrameViewDidLoadUrl', this, src) ;
  },

  /** @private */
  _contentDidChange: function(target,key,value,propertyRevision) {
    // handle changes to the content...
    if ((value = this.get('content')) != this._field_content) {

      // get the handler method
      var f = this._contentPropertyDidChange ;
      
      // stop listening to old content.
      if (this._field_content) {
        if (SC.isArray(this._field_content)) {
          this._field_content.invoke('removeObserver', '*', this, f) ;
        } else if (this._field_content.removeObserver) {
          this._field_content.removeObserver('*', this, f) ;
        }
      }
      
      // start listening for changes on the new content object.
      this._field_content = value ;
      if (value) {
        if (SC.isArray(value)) {
          value.invoke('addObserver', '*', this, f) ;
        } else if (value.addObserver) {
          value.addObserver('*', this, f) ;
        }
      }

      // notify everyone that everything is different now.
{'fraction_non_alphanumeric': 0.19227658714112414, 'fraction_numerical': 0.007682976142337242, 'mean_word_length': 2.8230293663060277, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '2247347', 'n_tokens_mistral': 1534, 'n_tokens_neox': 1450, 'n_words': 330}