Version 1
[yaffs-website] / web / modules / contrib / linkit / js / attribute / title.js
diff --git a/web/modules/contrib/linkit/js/attribute/title.js b/web/modules/contrib/linkit/js/attribute/title.js
new file mode 100644 (file)
index 0000000..a2bb7a1
--- /dev/null
@@ -0,0 +1,21 @@
+/**
+ * @file
+ * Title attribute functions.
+ */
+
+(function ($, Drupal, document) {
+
+  'use strict';
+
+  var fieldName = '[name="attributes[title]"]';
+
+  /**
+   * Automatically populate the title attribute.
+   */
+  $(document).bind('linkit.autocomplete.select', function (triggerEvent, event, ui) {
+    if (ui.item.hasOwnProperty('title')) {
+      $('form.linkit-editor-dialog-form').find(fieldName).val(ui.item.title);
+    }
+  });
+
+})(jQuery, Drupal, document);