Fills in CKeditor

 Example usage:
 fill_in_ckeditor 'email_body', :with => 'This is my message!'

 @param locator [String] Used to locate the editor
 @param opts [Hash] contains what to fill the editor with and other options (See Capybara docs)
193764
def fill_in_ckeditor(locator, opts)
      sleep 1
      content = opts.fetch(:with).to_json
      page.execute_script <<-SCRIPT
              CKEDITOR.instances['#{locator}'].setData(#{content});
                                                           $('textarea##{locator}').text(#{content});
      SCRIPT
    end
1063392
def find_email(address, opts={})
      address = convert_address(address)
      if opts[:with_subject]
        expected_subject = (opts[:with_subject].is_a?(String) ? Regexp.escape(opts[:with_subject]) : opts[:with_subject])
        mailbox_for(address).find { |m| m.subject =~ Regexp.new(expected_subject) }
      elsif opts[:with_text]
        expected_text = (opts[:with_text].is_a?(String) ? Regexp.escape(opts[:with_text]) : opts[:with_text])
        mailbox_for(address).find { |m| m.default_part_body =~ Regexp.new(expected_text) }
      elsif opts[:from]
        mailbox_for(address).find { |m| m.from.include? opts[:from] }
      else
        mailbox_for(address).first
      end
    end
963785
def call(word, opts)
      validate_opts!(opts)
      driver = Smartdict::Core::DriverManager.find(opts[:driver])

      translation_model = Models::Translation.find(word, opts[:from_lang], opts[:to_lang], opts[:driver])
      unless translation_model
        translation = driver.translate(word, opts[:from_lang], opts[:to_lang])
        translation_model = Models::Translation.create_from_struct(translation)
      end
      log_query(translation_model) if opts[:log]
      translation_model.to_struct
    end
501840
def get_settings
      warning_opts = get_warning_options
      Trollop::options do
        banner 'LASER: Lexically- and Semantically-Enriched Ruby'
        opt :fix, 'Should errors be fixed in-line?', short: '-f'
        opt :display, 'Should errors be displayed?', short: '-b', default: true
        opt :'report-fixed', 'Should fixed errors be reported anyway?', short: '-r'
        opt :'line-length', 'Warn at the given line length', short: '-l', type: :int
        opt :only, 'Only consider the given warning (by short or full name)', short: '-O', type: :string
        opt :stdin, 'Read Ruby code from standard input', short: '-s'
        opt :'list-modules', 'Print the discovered, loaded modules'
        opt :profile, 'Run the profiler during execution'
        opt :include, 'specify $LOAD_PATH directory (may be used more than once)', short: '-I', multi: true
        opt :S, 'look for scripts using PATH environment variable', short: '-S'
        warning_opts.each { |warning| opt(*warning) }
      end
    end
67503
function Autocomplete(el, options) {
      _classCallCheck(this, Autocomplete);

      var _this38 = _possibleConstructorReturn(this, (Autocomplete.__proto__ || Object.getPrototypeOf(Autocomplete)).call(this, Autocomplete, el, options));

      _this38.el.M_Autocomplete = _this38;

      /**
       * Options for the autocomplete
       * @member Autocomplete#options
       * @prop {Number} duration
       * @prop {Number} dist
       * @prop {number} shift
       * @prop {number} padding
       * @prop {Boolean} fullWidth
       * @prop {Boolean} indicators
       * @prop {Boolean} noWrap
       * @prop {Function} onCycleTo
       */
      _this38.options = $.extend({}, Autocomplete.defaults, options);

      // Setup
      _this38.isOpen = false;
      _this38.count = 0;
      _this38.activeIndex = -1;
      _this38.oldVal;
      _this38.$inputField = _this38.$el.closest('.input-field');
      _this38.$active = $();
      _this38._setupDropdown();

      _this38._setupEventHandlers();
      return _this38;
    }
1140312
function(opts) {
			var i, n, options, label, self = this;
			opts = opts || {};
	
			if (self.tagType === TAG_SELECT) {
				options = [];
				for (i = 0, n = self.items.length; i < n; i++) {
					label = self.options[self.items[i]][self.settings.labelField] || '';
					options.push('<option value="' + escape_html(self.items[i]) + '" selected="selected">' + escape_html(label) + '</option>');
				}
				if (!options.length && !this.$input.attr('multiple')) {
					options.push('<option value="" selected="selected"></option>');
				}
				self.$input.html(options.join(''));
			} else {
				self.$input.val(self.getValue());
				self.$input.attr('value',self.$input.val());
			}
	
			if (self.isSetup) {
				if (!opts.silent) {
					self.trigger('change', self.$input.val());
				}
			}
		}
1146824
function (str, opts) {
    opts = extend({marker: 'snippet', action: 'add'}, opts);
    opts = extend({}, this.options, opts);

    var snippet = this.toSnippet(str, opts);
    return utils.inject(this, snippet, opts);
  }
429829
function() {
      
      this.editorContainer = inputEx.cn('div', {className: CSS_PREFIX+'editor'}, {display: 'none'});
      
      //  field
      this.editorField = inputEx(this.options.editorField,this);
      var editorFieldEl = this.editorField.getEl();
      
      this.editorContainer.appendChild( editorFieldEl );
      Dom.addClass( editorFieldEl , CSS_PREFIX+'editorDiv');
      
      this.okButton = new inputEx.widget.Button({
         type: this.options.buttonTypes.ok,
         parentEl: this.editorContainer,
         value: inputEx.messages.okEditor,
         className: "inputEx-Button "+CSS_PREFIX+'OkButton',
         onClick: {fn: this.onOkEditor, scope:this}
      });

      this.cancelLink = new inputEx.widget.Button({
         type: this.options.buttonTypes.cancel,
         parentEl: this.editorContainer,
         value: inputEx.messages.cancelEditor,
         className: "inputEx-Button "+CSS_PREFIX+'CancelLink',
         onClick: {fn: this.onCancelEditor, scope:this}
      });
      
      // Line breaker ()
      this.editorContainer.appendChild( inputEx.cn('div',null, {clear: 'both'}) );
      
      this.fieldContainer.appendChild(this.editorContainer);
      
   }
48444
function( element ) {
				// Prepare for the insertion. For example - focus editor (#11848).
				beforeInsert( this );

				var editor = this.editor,
					enterMode = editor.activeEnterMode,
					selection = editor.getSelection(),
					range = selection.getRanges()[ 0 ],
					elementName = element.getName(),
					isBlock = CKEDITOR.dtd.$block[ elementName ];

				// Insert element into first range only and ignore the rest (#11183).
				if ( this.insertElementIntoRange( element, range ) ) {
					range.moveToPosition( element, CKEDITOR.POSITION_AFTER_END );

					// If we're inserting a block element, the new cursor position must be
					// optimized. (#3100,#5436,#8950)
					if ( isBlock ) {
						// Find next, meaningful element.
						var next = element.getNext( function( node ) {
							return isNotEmpty( node ) && !isBogus( node );
						} );

						if ( next && next.type == CKEDITOR.NODE_ELEMENT && next.is( CKEDITOR.dtd.$block ) ) {
							// If the next one is a text block, move cursor to the start of it's content.
							if ( next.getDtd()[ '#' ] )
								range.moveToElementEditStart( next );
							// Otherwise move cursor to the before end of the last element.
							else
								range.moveToElementEditEnd( element );
						}
						// Open a new line if the block is inserted at the end of parent.
						else if ( !next && enterMode != CKEDITOR.ENTER_BR ) {
							next = range.fixBlock( true, enterMode == CKEDITOR.ENTER_DIV ? 'div' : 'p' );
							range.moveToElementEditStart( next );
						}
					}
				}

				// Set up the correct selection.
				selection.selectRanges( [ range ] );

				afterInsert( this );
			}
283919
def click_link_with_text(link_text, opts = {})
        if opts && opts[:index]
          elements = find_elements(:link_text, link_text)
          elements[opts[:index]-1].click
        else
          find_element(:link_text, link_text).click
        end
      end
194119
function Autocomplete(el, options) {
      _classCallCheck(this, Autocomplete);

      var _this37 = _possibleConstructorReturn(this, (Autocomplete.__proto__ || Object.getPrototypeOf(Autocomplete)).call(this, Autocomplete, el, options));

      _this37.el.M_Autocomplete = _this37;

      /**
       * Options for the autocomplete
       * @member Autocomplete#options
       * @prop {Number} duration
       * @prop {Number} dist
       * @prop {number} shift
       * @prop {number} padding
       * @prop {Boolean} fullWidth
       * @prop {Boolean} indicators
       * @prop {Boolean} noWrap
       * @prop {Function} onCycleTo
       */
      _this37.options = $.extend({}, Autocomplete.defaults, options);

      // Setup
      _this37.isOpen = false;
      _this37.count = 0;
      _this37.activeIndex = -1;
      _this37.oldVal;
      _this37.$inputField = _this37.$el.closest('.input-field');
      _this37.$active = $();
      _this37._mousedown = false;
      _this37._setupDropdown();

      _this37._setupEventHandlers();
      return _this37;
    }
87834
function SallyWriter(opts)
{
	this.sally = require('./sally');
	
	opts = opts || {};
	this.path = opts.path || 'sally.log';
	this.prefix = opts.prefix || '';
	this.digest = undefined;
	this.onLog = this.onLog.bind(this);
	this.onEpochStart = this.onEpochStart.bind(this);
	this.onEpochEnd = this.onEpochEnd.bind(this);
	this.onCycleStart = this.onCycleStart.bind(this);
	this.onCycleEnd = this.onCycleEnd.bind(this);
	this.sally
		.on('log', this.onLog)
		.on('epochStart', this.onEpochStart)
		.on('epochEnd', this.onEpochEnd)
		.on('cycleStart', this.onCycleStart)
		.on('cycleEnd', this.onCycleEnd)
		.configure(opts);
}
1156003
function (editor, message, callback) {
      var rng = editor.selection.getRng();

      Delay.setEditorTimeout(editor, function () {
        editor.windowManager.confirm(message, function (state) {
          editor.selection.setRng(rng);
          callback(state);
        });
      });
    }
1037381
function plugin (opts) {
  opts = opts || {}
  var dir = opts.directory

  /*
   * Fix for resolving local path
   * @param {Metalsmith} metalsmith The metalsmith instance
   * @returns The absolute path including initial globbing pattern
   */
  function resolvePath(metalsmith) {
    var globStart = false;                            // Indicator, if globbing pattern was found yet
    var cwd = metalsmith.directory();                 // Get Metalsmith working directory
    var subPath = [];
    var pattern = [];
    var directory = dir.split('/');
    directory.forEach(function parsePathElems(elem) {
      if (globStart || elem.search(/[^a-z0-9\.\-_]/gi) >= 0) {   // Search in current path segment for glob patterns
        globStart = true;                 // If true, set globStart to true
        return pattern.push(elem);        // add to pattern now and in future automatically
      }
      return subPath.push(elem);
    });

    // Now check if calculated path is existing (absolute vs relative position to Metalsmith CWD)
    var localPath = path.resolve(cwd, subPath.join('/'));   // Assume path is relative to CWD, e.g. ./src/*.json
    if (!fs.existsSync(path.resolve(cwd, localPath))) {
      localPath = path.relative(cwd, subPath.join('/'));    // Assumption false, it was absolute, e.g. ./test/fixtures/...
    }

    return path.resolve(cwd, localPath, pattern.join('/')); // return correct path
  }

  return function (files, metalsmith, done) {
    var metadata = metalsmith.metadata()

    debug('Original Metalsmith metadata', metadata)

    // Get all files from specified directory
    if (Array.isArray(dir)) {
      dir = dir.map(function (d) {
        resolvePath(d);                   // Do for every member in array
      });
    } else {
      dir = resolvePath(metalsmith);     // Get previously calculated correct path
    }
    glob(dir, function (err, files) {
      if (err) {
        done(new Error('Glob error: ' + err))
      }

      debug('Number of files found by Glob', files.length)
      debug('Files found by Glob', files)

      // Error if directory is empty
      if (files.length === 0) {
        done(new Error('No files found in directory: ' + dir))
      }

      // For each found file
      async.forEach(files, function (file, callback) {
        var fileName = path.basename(file)
        var suffix = /\.([a-z]+)$/i.exec(fileName);
        var theKey = fileName.replace(/\.[^/.]+$/, '')
        var theContents = fs.readFileSync(file, 'utf8')

        // Error if the key already exists (duplicate file name)
        if (theKey in metadata) {
          return done(new Error('Duplicate file name: ' + fileName))
        }

        // Ignore file if it is empty
        if (theContents.length === 0) {
          return done()
        }

        if (suffix && suffix[1] && suffix[1].toLowerCase() === 'yml') {
          // Okay, we detected a file with 'yml' as suffix, let's try to parse it.
          try {
            var json = yaml(theContents);
          } catch (error) {
            return done(error);
          }
        } else {
          // Check to see if JSON is malformed
          try {
            var json = JSON.parse(theContents)
          } catch (error) {
            return done(new Error('Malformed data in: ' + fileName))
          }
        }

        // Debug information
        debug('File name read', file)
        debug('File key', theKey)
        debug('File JSON contents', theContents)

        // Add to metalsmith metadata
        metadata[theKey] = json
        callback()

      }, function (err) {
        debug('Async callback triggered')

        if (err) {
          done(new Error('Async error: ' + err))
        }

        debug('New Metalsmith metadata', metadata)
        done()
      })
    })
  }
}
104233
def show
      prevent_browser_caching
      cms_edit_links!
      with_email_locale do
        if @preview.respond_to?(:preview_mail)
          @mail, body     = mail_and_body
          @mail_body_html = render_to_string(inline: body, layout: 'rails_email_preview/email')
        else
          raise ArgumentError.new("#{@preview} is not a preview class, does not respond_to?(:preview_mail)")
        end
      end
    end
7672
function getSearchRange( isDefault ) {
				var searchRange,
					sel = editor.getSelection(),
					editable = editor.editable();

				if ( sel && !isDefault ) {
					searchRange = sel.getRanges()[ 0 ].clone();
					searchRange.collapse( true );
				} else {
					searchRange = editor.createRange();
					searchRange.setStartAt( editable, CKEDITOR.POSITION_AFTER_START );
				}
				searchRange.setEndAt( editable, CKEDITOR.POSITION_BEFORE_END );
				return searchRange;
			}
941418
def set_hidden_field(field_locator, options = {})
      field = locate_field(field_locator, HiddenField)
      field.set(options[:to])
    end