+ Zastap.prototype.wrap_words = function(element, wrapper) {
+ var chld, i, ignore, insertWrapped, j, len, space, wordb, _ref, _results;
+ ignore = /^[ \t.,:;()]+/;
+ insertWrapped = function(txt, elem) {
+ var nw;
+ nw = wrapper.clone();
+ return $(document.createTextNode(txt)).wrap(nw).parent().attr("data-original", txt).insertBefore(elem);
+ };
+ _results = [];
+ for (j = _ref = element.get(0).childNodes.length - 1; _ref <= 0 ? j <= 0 : j >= 0; _ref <= 0 ? j++ : j--) {
+ chld = element.get(0).childNodes[j];
+ if (chld.nodeType === document.TEXT_NODE) {
+ len = chld.textContent.length;
+ wordb = 0;
+ i = 0;
+ while (i < len) {
+ space = ignore.exec(chld.textContent.substr(i));
+ if (space != null) {
+ if (wordb < i) {
+ insertWrapped(chld.textContent.substr(wordb, i - wordb), chld);
+ }
+ $(document.createTextNode(space[0])).insertBefore(chld);
+ i += space[0].length;
+ wordb = i;
+ } else {
+ i = i + 1;
+ }
+ }
+ if (wordb < len - 1) {
+ insertWrapped(chld.textContent.substr(wordb, len - 1 - wordb), chld);
+ }
+ _results.push($(chld).remove());
+ } else {
+ _results.push(void 0);
+ }
+ }
+ return _results;
+ };
+
+ return Zastap;
+
+ })(Excercise);
+
+ Przyporzadkuj = (function(_super) {
+
+ __extends(Przyporzadkuj, _super);
+
+ function Przyporzadkuj(element) {
+ var _this = this;
+ Przyporzadkuj.__super__.constructor.call(this, element);
+ if (this.element.attr('multiple') != null) {
+ this.multiple = true;
+ } else {
+ this.multiple = false;
+ }
+ $(".question", this.element).each(function(i, question) {
+ var draggable_opts;
+ draggable_opts = {
+ revert: 'invalid',
+ helper: _this.multiple ? "clone" : null
+ };
+ $(".draggable", question).draggable(draggable_opts).droppable({
+ accept: ".draggable"
+ });
+ $(".predicate .droppable", question).droppable({
+ accept: ".draggable",
+ drop: function(ev, ui) {
+ var added, is_multiple;
+ is_multiple = ui.draggable.is(".multiple");
+ added = ui.draggable.clone();
+ added.attr('style', '');
+ $(this).append(added);
+ added.draggable(draggable_opts);
+ if (!is_multiple) return ui.draggable.remove();
+ }
+ });
+ return $(".subject", question).droppable({
+ accept: ".draggable",
+ drop: function(ev, ui) {
+ var added, is_multiple;
+ is_multiple = ui.draggable.is(".multiple");
+ added = ui.draggable.clone();
+ added.attr('style', '');
+ if (!is_multiple) {
+ $(this).append(added);
+ added.draggable(draggable_opts);
+ }
+ return ui.draggable.remove();
+ }
+ });
+ });
+ }
+
+ return Przyporzadkuj;