Implements the 'vimeo' snippet
962829
public function vimeo($link, $width=480, $height=360, $portrait=true, $title=true, $byline=true) {
		$matches = array();
		$regexp = '/(https?:\/\/)?(www\.)?(player\.)?vimeo\.com\/([a-z]*\/)*(?\'video_id\'[0-9]{6,11})[?]?.*/';
		if (preg_match_all($regexp, $link, $matches)) {
			if (array_key_exists('video_id', $matches)) {
				$embed = "//player.vimeo.com/video/" . $matches['video_id'][0];

				$opts = array();
				if (!$this->isTrue($portrait)) { $opts[] = "portrait=0"; }
				if (!$this->isTrue($title))    { $opts[] = "title=0"; }
				if (!$this->isTrue($byline))   { $opts[] = "byline=0"; }
				if (count($opts)>0) {
					$embed .="?" . implode("&amp;", $opts);
				}

				return "<iframe width=\"$width\" height=\"$height\" src=\"$embed\" frameborder=\"0\" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>";
			}
		}
	}
419359
function() {
		var self = this,
			url_vars;

		this.youtube_loaded = false;

		// Create Dom element
		this._el.content_item	= TL.Dom.create("div", "tl-media-item tl-media-youtube tl-media-shadow", this._el.content);
		this._el.content_item.id = TL.Util.unique_ID(7)

		// URL Vars
		url_vars = TL.Util.getUrlVars(this.data.url);

		// Get Media ID
		this.media_id = {};

		if (this.data.url.match('v=')) {
			this.media_id.id	= url_vars["v"];
		} else if (this.data.url.match('\/embed\/')) {
			this.media_id.id	= this.data.url.split("embed\/")[1].split(/[?&]/)[0];
		} else if (this.data.url.match(/v\/|v=|youtu\.be\//)){
			this.media_id.id	= this.data.url.split(/v\/|v=|youtu\.be\//)[1].split(/[?&]/)[0];
		} else {
			trace("YOUTUBE IN URL BUT NOT A VALID VIDEO");
		}

		// Get start second
		if (this.data.url.match("start=")) {
			this.media_id.start = parseInt(this.data.url.split("start=")[1], 10);
		}
		else if (this.data.url.match("t=")) {
			this.media_id.start = parseInt(this.data.url.split("t=")[1], 10);
		}

		//Get end second
		if (this.data.url.match("end=")) {
			this.media_id.end = parseInt(this.data.url.split("end=")[1], 10);
		}

		this.media_id.hd		= Boolean(typeof(url_vars["hd"]) != 'undefined');


		// API Call
		TL.Load.js('https://www.youtube.com/iframe_api', function() {
			self.createMedia();
		});

	}
1285165
function YouTubeModal(config) {
  this.config = config;
  this.parentElement = document.querySelector(this.config.parentSelector);
  this.closeEventListener_ = this.setActive_.bind(this, false);
  this.popstateListener_ = this.onHistoryChange_.bind(this);
  this.el_ = null;
  this.closeEl_ = null;
  this.attributionEl_ = null;
  this.initDom_();
  this.lastActiveVideoId_ = null;
  this.scrollY = 0;

  this.delegatedListener_ = function(targetEl) {
    var data = 'data-' + this.config.className + '-video-id';
    var videoId = targetEl.getAttribute(data);
    var startDataAttribute = 'data-' + this.config.className + '-video-start-seconds';
    var startTime = +targetEl.getAttribute(startDataAttribute);
    var attributionAttribute = 'data-' + this.config.className + '-attribution';
    var attribution = targetEl.getAttribute(attributionAttribute);
    if (videoId) {
      this.play(videoId, true /* opt_updateState */, startTime, attribution);
    }
  }.bind(this);

  // Loads YouTube iframe API.
  events.addDelegatedListener(document, 'click', this.delegatedListener_);

  // Only add the script tag if it doesn't exist
  var scriptTag =
    document.querySelector('script[src="https://www.youtube.com/iframe_api"]');
  if (!scriptTag) {
    var tag = document.createElement('script');
    tag.setAttribute('src', 'https://www.youtube.com/iframe_api');
    this.parentElement.appendChild(tag);
  }
}
278206
function clVideoTransformation() {
        return {
            restrict: 'E',
            transclude: false,
            require: '^clVideo',
            link: function (scope, element, attrs, clVideoCtrl) {
                var attributes = getAttributes(attrs);
                clVideoCtrl.addTransformation(attributes);
            }
        };
    }
33381
def get_require_snippet(require_file, scope)
      ERB.new(SublimeSunippetter::Templates::REQUIRE_SUNIPPET_TEMPLATE).result(binding)
    end
892321
def parse_snippet_css(path)
      return unless core.storage.file?(path)
      parser = ::CssParser::Parser.new
      parser.add_block! core.storage.read(path)
      apply_styles parser, "snippet"
    end
179966
def edit(snippet)
      if editor && !editor.empty?
        snippet_file = file_for(snippet)
        Process.exec "#{editor} '#{snippet_file}'"
      end
    end
342702
public function getVideo()
    {
        // This function is based on code by Wouter Sioen released under the MIT license
        // see woutersioen/sir-trevor-php
        // Regexps from http://stackoverflow.com/questions/10488943/easy-way-to-get-vimeo-id-from-a-vimeo-url
        // and http://stackoverflow.com/questions/3452546/javascript-regex-how-to-get-youtube-video-id-from-url
        if (preg_match('/.*(?:youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=)([^#\&\?]*).*/', $this->getVideoUrl(), $matches)) {
            $data = array(
                'source' => 'youtube',
                'remote_id' => $matches[1]
            );
        } elseif (preg_match('/(?:https?:\/\/)?(?:www\.)?(?:player\.)?vimeo\.com\/([a-z]*\/)*([0-9]{6,11})[?]?.*/', $this->getVideoUrl(), $matches)) {
            $data = array(
                'source' => 'vimeo',
                'remote_id' => $matches[2]
            );
        } else {
            throw new \FelixOnline\Exceptions\InternalException('The specified video URL is not valid');
        }

        if ($data['source'] == 'youtube') {
            $html = '<iframe src="//www.youtube.com/embed/' . $data['remote_id'] . '?rel=0" ';
            $html .= 'frameborder="0" allowfullscreen></iframe>' . "\n";
        } else {
            $html = '<iframe src="//player.vimeo.com/video/' . $data['remote_id'];
            $html .= '?title=0&amp;byline=0" frameborder="0"></iframe>' . "\n";
        }

        return $html;
    }
571828
def run(self, snippet):
        
        assert snippet[0] == ':'
        snippet = snippet[1:]
        snippet_args = _parse_snippet(snippet)
        name = snippet_args[0]

        logger.info("Processing snippet `%s`.", snippet)
        try:
            # Try to run the snippet on all attached Actions instances.
            for actions in self.gui.actions:
                try:
                    actions.run(name, *snippet_args[1:])
                    return
                except ValueError:
                    # This Actions instance doesn't contain the requested
                    # snippet, trying the next attached Actions instance.
                    pass
            logger.warn("Couldn't find action `%s`.", name)
        except Exception as e:
            logger.warn("Error when executing snippet: \"%s\".", str(e))
            logger.debug(''.join(traceback.format_exception(*sys.exc_info())))
303781
protected function overrideVideo() {
		/**
		 * @param string $output  Video shortcode HTML output.
		 * @param array  $atts    Array of video shortcode attributes.
		 * @param string $video   Video file.
		 */
		add_filter(
			'wp_video_shortcode', function ( $output, $atts, $video ) {
				$src_attributes = array_merge( [ 'src' ], wp_get_video_extensions() );
				foreach ( $src_attributes as $attribute ) {
					if ( ! empty( $atts[ $attribute ] ) ) {
						$src = $atts[ $attribute ];
						break;
					}
				}
				if ( empty( $src ) ) {
					$src = $video;
				}
				$type = wp_check_filetype( $src, wp_get_mime_types() )['type'];
				$output = "<video class='wp-video-shortcode' controls='controls'><source type='{$type}' src='{$src}' /><a href='{$src}'>{$src}</a></video>";
				return $output;
			}, 10, 3
		);
	}
142331
public function vimeo($vimeo = null, array $options = array()) {
        if (!func_num_args()) {
            return $this;
        }
        return $this->render($vimeo, $options);
    }
473201
function (val, opts) {
    if (typeof val === 'function') {
      return new Snippet(val(this));
    }
    if (typeof val === 'string') {
      var str = utils.tryRead(val);
      var res = {content: null, options: opts || {}};
      if (str) {
        res.path = val;
        res.content = str.toString();
      } else {
        res.content = val;
      }
      return new Snippet(res);
    }
    if (val instanceof Snippet) {
      val.option(opts);
      return val;
    }
    if (typeof val === 'object') {
      val.options = extend({}, val.options, opts);
      return new Snippet(val);
    }
  }
1336498
public function getThumbnail()
    {
        if (!isset($this->params['id'])) {
            $this->params['thumbnail'] = '';
        }

        $requestThumb = wp_remote_get('http://vimeo.com/api/v2/video/' . $this->params['id'] . '.json');
        $requestThumb = json_decode(wp_remote_retrieve_body($requestThumb));
        $thumbnail = $requestThumb[0]->thumbnail_large;

        $this->params['thumbnail'] = $thumbnail;
    }
1181740
def visit_snippet(self, node):
    
    lang = self.highlightlang
    linenos = node.rawsource.count('\n') >= self.highlightlinenothreshold - 1
    fname = node['filename']
    highlight_args = node.get('highlight_args', {})
    if 'language' in node:
        # code-block directives
        lang = node['language']
        highlight_args['force'] = True
    if 'linenos' in node:
        linenos = node['linenos']

    def warner(msg):
        self.builder.warn(msg, (self.builder.current_docname, node.line))

    highlighted = self.highlighter.highlight_block(node.rawsource, lang,
                                                   warn=warner,
                                                   linenos=linenos,
                                                   **highlight_args)
    starttag = self.starttag(node, 'div', suffix='',
                             CLASS='highlight-%s snippet' % lang)
    self.body.append(starttag)
    self.body.append('<div class="snippet-filename">%s</div>\n''' % (fname,))
    self.body.append(highlighted)
    self.body.append('</div>\n')
    raise nodes.SkipNode
396719
def each_child_snippet(snippet, context, base_tag)
      raise "must be passed snippet" unless snippet.is_a?(Snippet)

      snippet.snip_tags.each do |tag_info|
        t = tag_info[:tag].set_by_tag(base_tag)
        new_context = context.clone

        if new_context.root_text?
          new_context.set_path ""
          move_context_by_tag! new_context, t
        else
          move_context_by_tag! new_context, t
          overwrite_tag_in_same_repository! new_context, t
          update_tag_path_by_context! new_context, t
        end

        resolve_tag_repo_ref! t
        child_snippet = core.repo_manager.get_snippet(new_context, t)
        t.set_path new_context.path

        if block_given?
          yield t, tag_info[:line_no], child_snippet, new_context
        end
      end
    end
414727
function Video (data) {
    const autoPlay = data.attr.autoPlay
    const playStatus = data.attr.playStatus
    this.autoPlay = autoPlay === true || autoPlay === 'true'
    if (playStatus !== 'play'
        && playStatus !== 'stop'
        && playStatus !== 'pause') {
      this.playStatus = 'pause'
    }
    else {
      this.playStatus = playStatus
    }
    Atomic.call(this, data)
  }
1026047
function onYouTubePlayerAPIReady() {
  // Loop through each iframe video on the page
  jQuery( "iframe.copy-video__video").each(function (index) {

    // Create IDs dynamically
    var iframeID = "js-copy-video-" + index;
    var buttonID = "js-copy-video-" + index + "__button";

    // Set IDs
    jQuery(this).attr('id', iframeID);
    jQuery(this).next('button.copy-video__button').attr('id', buttonID);

    // Associate video player with button via index
    players[buttonID] = { player: null, }

    // Set-up a player object for each video
    players[buttonID].player =  new YT.Player(iframeID, {
      events: { 'onReady': onPlayerReady }
    });
  });
}