o: ActiveSupport::Cache::Entry	:@compressedF:@expires_in0:@created_atf1364339933.266198:@value"e#{I"
class:EFI"ProcessedAsset;�FI"logical_path;�FI"!wymeditor/browsers/webkit.js;�TI"
pathname;�FI"�/Users/johanfrolich/.rvm/gems/ruby-1.9.3-p327@refinerycms-menus/gems/refinerycms-core-2.0.9/app/assets/javascripts/wymeditor/browsers/webkit.js.erb;�TI"content_type;�FI"application/javascript;�FI"
mtime;�FI"2013-02-04T15:34:04+01:00;�FI"length;�FitI"digest;�F"%dd117bbb39a036bb471201e62fb30d4cI"source;�FI"t/*
 * WYMeditor : what you see is What You Mean web-based editor
 * Copyright (c) 2005 - 2009 Jean-Francois Hovinne, http://www.wymeditor.org/
 * Dual licensed under the MIT (MIT-license.txt)
 * and GPL (GPL-license.txt) licenses.
 *
 * For further information visit:
 *        http://www.wymeditor.org/
 *
 * File Name:
 *        jquery.wymeditor.safari.js
 *        Safari specific class and functions.
 *        See the documentation for more info.
 *
 * File Authors:
 *        Jean-Francois Hovinne (jf.hovinne a-t wymeditor dotorg)
 *        Scott Lewis (lewiscot a-t gmail dotcom)
 */


WYMeditor.WymClassSafari = function(wym) {

    this._wym = wym;
    this._class = "class";
    this._newLine = "\n";
};

WYMeditor.WymClassSafari.prototype.initIframe = function(iframe) {

    this._iframe = iframe;
    this._doc = iframe.contentDocument;

    //add css rules from options

    var styles = this._doc.styleSheets[0];
    var aCss = eval(this._options.editorStyles);

    this.addCssRules(this._doc, aCss);

    this._doc.title = this._wym._index;

    //set the text direction
    $('html', this._doc).attr('dir', this._options.direction);

    //init designMode
    this._doc.designMode = "on";

    //init html value
    this.html(this._wym._html);

    //pre-bind functions
    if($.isFunction(this._options.preBind)) this._options.preBind(this);

    //bind external events
    this._wym.bindEvents();

    //bind editor keydown events
    $(this._doc).bind("keydown", this.keydown);

    //bind editor keyup events
    $(this._doc).bind("keyup", this.keyup);

    // bind paste events
    $(this._doc).bind("paste", this.intercept_paste);

    //post-init functions
    if($.isFunction(this._options.postInit)) this._options.postInit(this);

    //add event listeners to doc elements, e.g. images
    this.listen();
};

WYMeditor.WymClassSafari.prototype._exec = function(cmd,param) {

    var wym = this;
    if(!wym.selected()) {
      return(false);
    }

    switch(cmd) {

    case WYMeditor.INDENT: case WYMeditor.OUTDENT:

        var focusNode = wym.selected();
        var sel = wym._iframe.contentWindow.getSelection();
        var anchorNode = sel.anchorNode;
        if(anchorNode.nodeName == "#text") {
          anchorNode = anchorNode.parentNode;
        }

        focusNode = wym.findUp(focusNode, WYMeditor.BLOCKS);
        anchorNode = wym.findUp(anchorNode, WYMeditor.BLOCKS);

        if(focusNode && focusNode == anchorNode
          && focusNode.tagName.toLowerCase() == WYMeditor.LI) {

            var ancestor = focusNode.parentNode.parentNode;

            if(focusNode.parentNode.childNodes.length > 1 || $.inArray(ancestor.tagName.toLowerCase(), [WYMeditor.OL, WYMeditor.UL]) > -1) {
                wym._doc.execCommand(cmd,'',null);
            }
        }

    break;

    case WYMeditor.INSERT_ORDEREDLIST: case WYMeditor.INSERT_UNORDEREDLIST:

        this._doc.execCommand(cmd,'',null);

        //Safari creates lists in e.g. paragraphs.
        //Find the container, and remove it.
        var focusNode = this.selected();
        var container = this.findUp(focusNode, WYMeditor.MAIN_CONTAINERS);
        if(container) $(container).replaceWith($(container).html());

    break;

    default:
      if(param) this._doc.execCommand(cmd,'',param);
      else this._doc.execCommand(cmd,'',null);
    }

};

/* @name selected
 * @description Returns the selected container
 */
WYMeditor.WymClassSafari.prototype.selected = function(upgrade_text_nodes) {

  if (upgrade_text_nodes == null || upgrade_text_nodes.toString() != "true") { upgrade_text_nodes = false; }
  var sel = this._iframe.contentWindow.getSelection();
  var node = sel.focusNode;
  if(node) {
      if(node.nodeName == "#text"){
        if (upgrade_text_nodes && sel.toString().length > 0) {
          actual_node = null;
          parent_node = sel.focusNode.parentNode;
          if (parent_node != null) {
            for (i=0;i<parent_node.childNodes.length;i++){
              child_node = parent_node.childNodes[i];
              if (child_node.textContent == sel.toString()){
                actual_node = child_node.parentNode;
              }
            }
          }

          if (actual_node == null) {
            this._selected_item = this.switchTo(sel, 'span');
            return this._selected_item;
          } else {
            return actual_node;
          }
        }
        else {
          return node.parentNode;
        }
      }
      else { return(node); }
  }
  else { return(null); }
};

/* @name toggleClass
 * @description Toggles class on selected element, or one of its parents
 */
WYMeditor.WymClassSafari.prototype.toggleClass = function(sClass, jqexpr) {

  var container = null;
  if (this._selected_image) {
    container = $(this._selected_image);
  }
  else {
    container = $(this.selected(true) || this._selected_item);
  }

  if (jqexpr != null) { container = $(container.parentsOrSelf(jqexpr)); }
  container.toggleClass(sClass);
  if(!container.attr(WYMeditor.CLASS)) container.removeAttr(this._class);

};

WYMeditor.WymClassSafari.prototype.addCssRule = function(styles, oCss) {

    styles.insertRule(oCss.name + " {" + oCss.css + "}",
        styles.cssRules.length);
};


//keydown handler, mainly used for keyboard shortcuts
WYMeditor.WymClassSafari.prototype.keydown = function(e) {

  //'this' is the doc
  var wym = WYMeditor.INSTANCES[this.title];

  if(e.ctrlKey){
    if(e.keyCode == 66){
      //CTRL+b => STRONG
      wym._exec(WYMeditor.BOLD);
      e.preventDefault();
    }
    if(e.keyCode == 73){
      //CTRL+i => EMPHASIS
      wym._exec(WYMeditor.ITALIC);
      e.preventDefault();
    }
  } else if(e.shiftKey && e.keyCode == 13) {
    wym._exec('InsertLineBreak');
    e.preventDefault();
  }
};

//keyup handler, mainly used for cleanups
WYMeditor.WymClassSafari.prototype.keyup = function(e) {

  //'this' is the doc
  var wym = WYMeditor.INSTANCES[this.title];

  wym._selected_image = null;
  $(wym._iframe).contents().find('.selected_by_wym').removeClass('selected_by_wym');
  var container = null;

  if(e.keyCode == 13 && !e.shiftKey) {
    //RETURN key
    //cleanup <br><br> between paragraphs
    $(wym._doc.body).children(WYMeditor.BR).remove();

    //fix PRE bug #73
    container = wym.selected();
    if(container && container.tagName.toLowerCase() == WYMeditor.PRE) {
      wym._exec(WYMeditor.FORMAT_BLOCK, WYMeditor.P); //create P after PRE
    }
  }

  else if(($.inArray(e.keyCode, [8, 17, 46, 224]) == -1) && !e.metaKey && !e.ctrlKey)
  {
    //NOT BACKSPACE, NOT DELETE, NOT CTRL, NOT COMMAND
    //text nodes replaced by P

    container = wym.selected();
    if (container && (name = container.tagName.toLowerCase())) {
      //fix forbidden main containers
      if($.inArray(name, ['strong', 'b', 'em', 'i', 'sub', 'sup', 'a', 'span']) > -1) {
        name = container.parentNode.tagName.toLowerCase();
      }

      if($.inArray(name, [WYMeditor.BODY, WYMeditor.DIV]) > -1) {
        wym._exec(WYMeditor.FORMAT_BLOCK, WYMeditor.P); //fix #110 for DIV
      }
    }
  }
};

WYMeditor.WymClassSafari.prototype.openBlockTag = function(tag, attributes)
{
  var attributes = this.validator.getValidTagAttributes(tag, attributes);

  // Handle Safari styled spans
  if(tag == 'span' && attributes.style) {
    if(new_tag = this.getTagForStyle(attributes.style)) {
      this._tag_stack.pop();
      var tag = new_tag;
      this._tag_stack.push(new_tag);
      attributes.style = '';

      //should fix #125 - also removed the xhtml() override
      if(typeof attributes['class'] == 'string') {
        attributes['class'] = attributes['class'].replace(/apple-style-span/gi, '');
      }

    } else {
      return;
    }
  }

  this.output += this.helper.tag(tag, attributes, true);
};

WYMeditor.WymClassSafari.prototype.getTagForStyle = function(style) {

  if(/bold/.test(style)) return 'strong';
  if(/italic/.test(style)) return 'em';
  if(/sub/.test(style)) return 'sub';
  if(/super/.test(style)) return 'sup';
  return false;
};
;�FI"dependency_digest;�F"%389f115bd4b956368ee923ade0dca1e2I"required_paths;�F[I"�/Users/johanfrolich/.rvm/gems/ruby-1.9.3-p327@refinerycms-menus/gems/refinerycms-core-2.0.9/app/assets/javascripts/wymeditor/browsers/webkit.js.erb;�TI"dependency_paths;�F[{I"	path;�FI"�/Users/johanfrolich/.rvm/gems/ruby-1.9.3-p327@refinerycms-menus/gems/refinerycms-core-2.0.9/app/assets/javascripts/wymeditor/browsers/webkit.js.erb;�TI"
mtime;�FI"2013-02-04T15:34:04+01:00;�FI"digest;�F"%48be97d3984592526792116d0f495b07I"
_version;�F"%ffd318ca8b794f42f5029101c2cf5d91