Permalink
Browse files

first commit

  • Loading branch information...
0 parents commit a3c2c60a9a0130f5112ae91da6d36f4799c417a3 @sergeche committed Jun 14, 2010
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>tx-content-assist</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.wst.jsdt.core.javascriptValidator</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.wst.jsdt.core.jsNature</nature>
+ </natures>
+</projectDescription>
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.baseBrowserLibrary"/>
+</classpath>
@@ -0,0 +1 @@
+org.eclipse.wst.jsdt.launching.baseBrowserLibrary
@@ -0,0 +1 @@
+Window
3 README
@@ -0,0 +1,3 @@
+Content assist support for textarea element. See demo here: http://media.chikuyonok.ru/content-assist/
+
+More documentation coming soon.
@@ -0,0 +1,101 @@
+.tx-ca-measurer {
+ position:absolute;
+ visibility:hidden;
+ top:0;
+ left:0;
+ z-index:1;
+ white-space:pre-wrap;
+}
+
+.tx-ca-measurer i {
+ display:inline-block;
+ zoom:1;
+ background:red;
+}
+
+.tx-ca-popup {
+ position:absolute;
+ background:#fff;
+ background:rgba(255,255,255,0.85);
+ z-index:10;
+ margin-top:1em;
+ padding:2px;
+ border:1px solid #d2d2d2;
+
+ -webkit-border-radius: 5px;
+ -moz-border-radius: 5px;
+ border-radius: 5px;
+
+ -webkit-box-shadow: 0 2px 2px rgba(0,0,0,0.1);
+ -moz-box-shadow: 0 3px 2px rgba(0,0,0,0.1);
+ -ms-box-shadow: 0 3px 2px rgba(0,0,0,0.1);
+ box-shadow: 0 2px 2px rgba(0,0,0,0.1);
+
+
+ -webkit-border-top-left-radius:2px;
+ -moz-border-radius-topleft:2px;
+ border-top-left-radius:2px;
+}
+
+.tx-ca-popup-content {
+ position:relative;
+ min-width:100px;
+ _width:100px;
+ overflow:auto;
+ overflow-x:hidden;
+}
+
+/* Content assist popup has scollable content */
+.tx-ca-popup-overflow .tx-ca-popup-content {
+ padding-right:2px;
+}
+
+.tx-proposal {
+ color:#242423;
+ font-family:'Lucida Grande', arial, sans-serif;
+ font-size:11px;
+ font-weight:bold;
+ line-height:20px; /* Set line-height in pixelx for better look in Firefox */
+ padding:0 4px 1px 4px;
+ cursor:pointer;
+ overflow:hidden;
+
+ -webkit-border-radius: 3px;
+ -moz-border-radius: 3px;
+ -ms-border-radius: 3px;
+ border-radius: 3px;
+
+ -webkit-border-top-left-radius:0;
+ -moz-border-radius-topleft:0;
+ border-top-left-radius:0;
+}
+
+.tx-proposal-selected {
+ position:relative;
+ background:#7a8da1;
+ background:-webkit-gradient(linear, left top, left bottom, from(#7a8da1), to(#455d75));
+ background-image:-moz-linear-gradient(top,#7a8da1,#455d75);
+ color:#fff;
+ text-shadow:0 1px 0 rgba(0,0,0,0.7);
+}
+
+/** neat scrollbars for Webkit */
+.tx-ca-popup-content::-webkit-scrollbar {
+ width:9px;
+ height:9px;
+}
+
+.tx-ca-popup-content::-webkit-scrollbar-track {
+ background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAHCAIAAABPxRC5AAAAPElEQVQImVWLwRGAMBCElou5/vuLtQQfPoz8GAbutWb3Ncacs7tLTaJSpVaSJIB7AwXkoE5Rv//X3wt4ACQ3F9lopNWrAAAAAElFTkSuQmCC) transparent 50% 0 repeat-y;
+ -webkit-border-radius:5px;
+}
+
+.tx-ca-popup-content::-webkit-scrollbar-thumb {
+ -webkit-border-radius:4px;
+ background:#c5c5c4;
+ background: -webkit-gradient(linear, left top, right top, from(#f9f9f9), to(#e6e6e6));
+ border:1px solid #d3d2d2;
+ left:0;
+ position:absolute;
+ -webkit-box-shadow:0 1px 1px rgba(0,0,0,0.1);
+}
@@ -0,0 +1 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Document</title> <script type="text/javascript" src="./src/tx_utils.js"></script> <script type="text/javascript" src="./src/EventDispatcher.js"></script> <script type="text/javascript" src="./src/TextViewer.js"></script> <script type="text/javascript" src="./src/ContentAssist.js"></script> <script type="text/javascript" src="./src/ContentAssistProcessor.js"></script> <script type="text/javascript" src="./src/CompletionProposal.js"></script> <script type="text/javascript" src="./src/BasicContentAssist.js"></script> <link rel="stylesheet" type="text/css" href="content-assist.css" media="all" /> <style type="text/css"> #wrap { position:relative; } #input { width:90%; height:10em; position:relative; display:block; } </style> </head> <body> <p>Type a few words starting from "a": for example, "awesome", "amazing".</p> <div id="wrap"> <textarea id="input"></textarea> </div> <script type="text/javascript"> var words = 'after,any,also,around,another,ask,again,air,away,animal,answer,america,awesome,amazing'.split(','); new BasicContentAssist(document.getElementById('input'), words); </script> </body></html>
@@ -0,0 +1,14 @@
+/**
+ * Basic content assist provides words proposal based on dictionary
+ * @class
+ * @param {Element} textarea Textarea element where you need to show content assist
+ * @param {Array} words Proposals (strings)
+ * @param {Object} [options] Options for <code>ContentAssist</code> object
+ *
+ * @author Sergey Chikuyonok (serge.che@gmail.com)
+ * @link http://chikuyonok.ru
+ */function BasicContentAssist(textarea, words, options) {
+ this.viewer = new TextViewer(textarea);
+ this.processor = new ContentAssistProcessor(words);
+ this.content_assist = new ContentAssist(this.viewer, this.processor, options);
+}
@@ -0,0 +1,54 @@
+/**
+ * Completition proposal
+ * @author Sergey Chikuyonok (serge.che@gmail.com)
+ * @link http://chikuyonok.ru
+ *
+ * @param {String} str The actual string to be inserted into the document
+ * @param {Number} offset The offset of the text to be replaced
+ * @param {Number} length The length of the text to be replaced
+ * @param {Number} cursor The position of the cursor following the insert
+ * relative to <code>offset</code>
+ *
+ * @include "TextViewer.js"
+ */function CompletionProposal(str, offset, length, cursor) {
+ this.str = str;
+ this.offset = offset;
+ this.len = length;
+ this.cursor = cursor;
+}
+
+CompletionProposal.prototype = {
+ /**
+ * Returns the string to be displayed in the list of completion proposals.
+ * @return {String}
+ */
+ getDisplayString: function() {
+ return this.str;
+ },
+
+ /**
+ * Inserts the proposed completion into the given document
+ * @param {TextViewer} viewer
+ */
+ apply: function(viewer) {
+ viewer.replaceText(this.str, this.offset, this.offset + this.len);
+ viewer.setCaretPos(this.cursor);
+ },
+
+ toString: function() {
+ return this.str;
+ },
+
+ /**
+ * Create DOM node for proposal
+ * @return {}
+ */
+ toHtml: function() {
+ var elem = document.createElement('div');
+ elem.className = 'tx-proposal';
+
+ elem.appendChild( document.createTextNode(this.getDisplayString()) );
+
+ return elem;
+ }
+}
Oops, something went wrong.

0 comments on commit a3c2c60

Please sign in to comment.