How to use the jquery.data function in jquery

To help you get started, we’ve selected a few jquery examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github bokeh / bokeh / bokehjs / src / vendor / jquery-event-2.2 / jquery.event.drop.js View on Github external
locate: function( elem, index ){
		var data = $.data( elem, drop.datakey ),
		$elem = $( elem ),
		posi = $elem.offset() || {},
		height = $elem.outerHeight(),
		width = $elem.outerWidth(),
		location = {
			elem: elem,
			width: width,
			height: height,
			top: posi.top,
			left: posi.left,
			right: posi.left + width,
			bottom: posi.top + height
		};
		// drag elements might not have dropdata
		if ( data ){
			data.location = location;
github mattgodbolt / compiler-explorer / static / views / settings.js View on Github external
function handleThemes() {
        var newTheme = themeSelect.val();
        // Store the scheme of the old theme
        $.data(themeSelect, 'theme-' + $.data(themeSelect, 'last-theme'), colourSchemeSelect.val());
        // Get the scheme of the new theme
        var newThemeStoredScheme = $.data(themeSelect, 'theme-' + newTheme);
        var isStoredUsable = false;
        colourSchemeSelect.empty();
        _.each(colour.schemes, function (scheme) {
            if (!scheme.themes || scheme.themes.length === 0 || scheme.themes.indexOf(newTheme) !== -1 ||
                scheme.themes.indexOf('all') !== -1) {

                colourSchemeSelect.append($('<option value="' + scheme.name + '">' + scheme.desc + "</option>"));
                if (newThemeStoredScheme === scheme.name) {
                    isStoredUsable = true;
                }
            }
        });
        if (colourSchemeSelect.children().length &gt;= 1) {
            colourSchemeSelect.val(isStoredUsable ? newThemeStoredScheme : colourSchemeSelect.first().val());
github mangalam-research / wed / lib / wed / decorator.js View on Github external
Decorator.prototype.elementDecorator = function elementDecorator(
    root, el, level, pre_context_handler, post_context_handler) {
    if (level &gt; this._editor.max_label_level) {
      throw new Error("level higher than the maximum set by the mode: " +
                      level);
    }

    // Save the caret because the decoration may mess up the GUI caret.
    var data_caret = this._editor.getDataCaret();
    if (data_caret &amp;&amp;
        !(data_caret.node instanceof this._editor.my_window.Attr &amp;&amp;
          data_caret.node.ownerElement === $.data(el, "wed_mirror_node"))) {
      data_caret = undefined;
    }

    var data_node = $.data(el, "wed_mirror_node");
    this.setReadOnly(el, this._editor.validator.getNodeProperty(
      data_node, "PossibleDueToWildcard"));

    var orig_name = util.getOriginalName(el);
    // _[name]_label is used locally to make the function idempotent.
    var cls = "_" + orig_name + "_label";

    // We must grab a list of nodes to remove before we start removing
    // them because an element that has a placeholder in it is going
    // to lose the placeholder while we are modifying it. This could
    // throw off the scan.
    var to_remove = domutil.childrenByClass(el, cls);
    var i;
    var remove;
    for (i = 0; i &lt; to_remove.length; ++i) {
      remove = to_remove[i];
github ecomfe / esui / src / behavior / Selectable.js View on Github external
function () {
                            var selectee = $.data(this, 'selectable-item');
                            me.removeClass(selectee.$element, 'unselecting');
                            selectee.unselecting = false;
                            selectee.startselected = false;
                            me.trigger('unselected', event, {unselected: selectee.element});
                        }
                    );
github mangalam-research / wed / lib / wed / domutil.js View on Github external
function linkTrees(root_a, root_b) {
    $.data(root_a, "wed_mirror_node", root_b);
    $.data(root_b, "wed_mirror_node", root_a);
    if (root_a.nodeType === Node.ELEMENT_NODE) {
      for (var i = 0; i &lt; root_a.childNodes.length; ++i) {
        var child_a = root_a.childNodes[i];
        var child_b = root_b.childNodes[i];
        linkTrees(child_a, child_b);
      }
    }
  }
github gitlabhq / gitlabhq / app / assets / javascripts / diff.js View on Github external
$diffFile.each((index, file) => {
      if (!$.data(file, 'singleFileDiff')) {
        $.data(file, 'singleFileDiff', new SingleFileDiff(file));
      }
    });
github stuartkeith / webaudiosequencer / source / javascript / baseView.js View on Github external
var touchstartWrapper = function (originals, event) {
			var target = $(event.currentTarget);

			var offset = target.offset();
			offset.right = offset.left + target.outerWidth();
			offset.bottom = offset.top + target.outerHeight();

			$.data(event.currentTarget, "touch", {
				touchMoveCount: 0,
				elementPosition: offset
			});

			event.pageX = pageX = event.originalEvent.changedTouches[0].pageX;
			event.pageY = pageY = event.originalEvent.changedTouches[0].pageY;
			event.which = 0;

			originals[0] && originals[0].call(this, event);

			event.which = 1;

			originals[1] && originals[1].call(this, event);
		};
github theatlantic / django-nested-admin / nested_admin / static / nested_admin / src / nested-admin / jquery.ui.djnsortable.js View on Github external
return false;
		}

		if(this.options.disabled || this.options.type == 'static') return false;

		//We have to refresh the items data once first
		this._refreshItems(event);

		//Find out if the clicked node (or one of its parents) is a actual item in this.items
		var currentItem = null, nodes = $(event.target).parents().each(function() {
			if($.data(this, that.widgetName + '-item') == that) {
				currentItem = $(this);
				return false;
			}
		});
		if($.data(event.target, that.widgetName + '-item') == that) currentItem = $(event.target);

		if(!currentItem) return false;
		if(this.options.handle && !overrideHandle) {
			var validHandle = false;
			var addBackMethod = ($.fn.addBack) ? 'addBack' : 'andSelf';

			$(this.options.handle, currentItem).find("*")[addBackMethod]().each(function() { if(this == event.target) validHandle = true; });
			if(!validHandle) return false;
		}

		this.currentItem = currentItem;
		this._removeCurrentsFromItems();
		return true;

	},
github ecomfe / esui / src / behavior / Selectable.js View on Github external
function () {
                                var $this = $(this);
                                var pos = $this.offset();
                                $.data(
                                    this,
                                    'selectable-item',
                                    {
                                        element: this,
                                        $element: $this,
                                        left: pos.left,
                                        top: pos.top,
                                        right: pos.left + $this.outerWidth(),
                                        bottom: pos.top + $this.outerHeight(),
                                        startselected: false,
                                        selected: me.hasClass('selected'),
                                        selecting: me.hasClass('selecting'),
                                        unselecting: me.hasClass('unselecting')
                                    }
                                );
                            }
github cloudera / hue / desktop / core / src / desktop / js / jquery / plugins / jquery.filechooser.js View on Github external
return this.each(function() {
    if (!$.data(this, 'plugin_' + pluginName)) {
      $.data(this, 'plugin_' + pluginName, new Plugin(this, options));
    } else {
      $.data(this, 'plugin_' + pluginName).setOptions(options);
    }
  });
};