Commit d3c5ffe1 authored by Jérome Perrin's avatar Jérome Perrin

Drop dependancy on underscore.js

replace underscore.js calls by their jquery equivalents
parent 040963d3
......@@ -55,8 +55,7 @@
-->
</div>
<!-- DEP -->
<script type="text/javascript" src="lib/underscore-min.js"></script>
<script type="text/javascript" src="lib/jquery-1.8.1-min.js"></script>
<script type="text/javascript" src="lib/jquery-1.8.1-min.js"></script>
<script type="text/javascript" src="lib/jquery-ui-1.8.23-min.js"></script>
<script type="text/javascript" src="lib/jquery.ui.touch-punch.min.js"></script>
<script type="text/javascript" src="lib/md5.js"></script>
......
This diff is collapsed.
......@@ -17,7 +17,7 @@
* along with DREAM. If not, see <http://www.gnu.org/licenses/>.
* =========================================================================== */
(function (scope, $, jsPlumb, console, _) {
(function (scope, $, jsPlumb, console) {
"use strict";
scope.Dream = function (configuration) {
var that = jsonPlumb(), priv = {};
......@@ -34,7 +34,7 @@
priv.updateBoxStyle = function (box_id, style) {
var box;
box = $("#" + box_id);
_.each(style, function(value, key, list) {
$.each(style, function(key, value) {
box.css(key, value);
})
};
......@@ -53,12 +53,12 @@
priv.displayTool = function() {
var render_element = $("[id=tools]");
_.each(_.pairs(configuration), function(value, key, list) {
if (value[0] !== 'Dream-Configuration') { // XXX
render_element.append('<div id="' + value[0] + '" class="tool">' +
value[0].split('-')[1] + "<ul/></div>");
for (var key in configuration) {
if (key !== 'Dream-Configuration') {
render_element.append('<div id="' + key + '" class="tool">' +
key.split('-')[1] + "<ul/></div>");
};
});
};
render_element.append('<p/><a id="clear_all">Clear All</a>');
};
......@@ -83,7 +83,8 @@
'<input type="text" name="' + prefix + property.id + '"' +
previous_value + ' id="' + prefix + property.id + '"' +
' class="text ui-widget-content ui-corner-all"/>');
}});
}
});
};
priv.prepareDialogForElement = function(title, element_id) {
......@@ -112,7 +113,7 @@
if (prefix === undefined) {
prefix = "";
}
_.each(property_list, function(property, key, list) {
$.each(property_list, function(key, property) {
if (property._class === "Dream.Property") {
console.log("property.id, previous_data", property.id, previous_data);
previous_value = previous_data[property.id] || "";
......@@ -160,10 +161,9 @@
if (prefix === undefined) {
prefix = "";
}
_.each(property_list, function(property, key, list) {
$.each(property_list, function(key, property) {
if (property._class === "Dream.Property") {
prefixed_property_id = prefix + property.id;
console.log("prefixed_property_id", prefixed_property_id);
property_element = $("#" + prefixed_property_id);
data[property.id] = property_element.val();
} else if (property._class === "Dream.PropertyList") {
......@@ -197,7 +197,7 @@
// Store default values
var data = {}, property_list = configuration[element_prefix]["property_list"] || [];
var updateDefaultData = function(data, property_list) {
_.each(property_list, function(element, key) {
$.each(property_list, function(key, element) {
console.log("going to parse property_list, element", element);
if(element._class === "Dream.Property") {
data[element.id] = element.default;
......@@ -220,8 +220,7 @@
priv.initDialog();
// save general configuration default values
var general_properties = {};
_.each(configuration["Dream-Configuration"].property_list, function(element, key) {
console.log("dream.start, parsing general property", element.id);
$.each(configuration["Dream-Configuration"].property_list, function(idx, element) {
general_properties[element.id] = element.default;
});
that.setGeneralProperties(general_properties);
......@@ -280,4 +279,4 @@
return that;
};
}(window, jQuery, jsPlumb, console, _));
}(window, jQuery, jsPlumb, console));
......@@ -17,7 +17,7 @@
* along with DREAM. If not, see <http://www.gnu.org/licenses/>.
* =========================================================================== */
(function($, _) {
(function($) {
"use strict";
jsPlumb.bind("ready", function() {
var dream_instance, available_people = {}, people_list,
......@@ -107,28 +107,27 @@
console.log("jio get:", response);
if (response !== undefined && response.data !== undefined) {
// Add all elements
_.each(response.data.element, function(value, key, list) {
$.each(response.data.element, function(key, value) {
var element_id = value.id;
var preference_data = response.data.preference !== undefined ? response.data.preference[element_id] : {};
_.each(_.pairs(preference_data), function(preference_value, preference_key, preference_list) {
value[preference_value[0]] = preference_value[1];
$.each(preference_data, function(preference_key, preference_value){
value[preference_key] = preference_value;
});
dream_instance.newElement(value);
dream_instance.updateElementData(element_id, {data: value.data || {}});
});
// Now link elements between them and update id_container
_.each(response.data.element, function(value, key, list) {
$.each(response.data.element, function(key, value) {
var element_id = value.id, prefix, suffix, splitted_element_id,
successor_list = value.successorList || [];
splitted_element_id = element_id.split("_");
prefix = splitted_element_id[0];
suffix = splitted_element_id[1];
id_container[prefix] = Math.max((id_container[prefix] || 0), parseInt(suffix, 10));
if (successor_list.length > 0) {
_.each(successor_list, function(successor_value, successor_key, list) {
dream_instance.connect(value.id, successor_value);
});
}
$.each(successor_list, function(idx, successor_value) {
dream_instance.connect(value.id, successor_value);
});
});
dream_instance.setGeneralProperties(response.data.general);
dream_instance.initGeneralProperties(); // XXX
......@@ -151,7 +150,7 @@
function(data) {
if (data['success']) {
$("#json_result").text(JSON.stringify(data['success'], undefined, " "));
$.each(data.coreObject, function(idx, obj){
$.each(data['success'].coreObject, function(idx, obj){
var e = $("#" + obj.id);
/* attach something to each corresponding core object */
// e.tooltip(JSON.stringify(obj['results'], undefined, " "));
......@@ -174,4 +173,4 @@
});
})
})(jQuery, _);
})(jQuery);
......@@ -17,7 +17,7 @@
* along with DREAM. If not, see <http://www.gnu.org/licenses/>.
* =========================================================================== */
(function (scope, $, jsPlumb, console, _) {
(function (scope, $, jsPlumb, console) {
"use strict";
scope.jsonPlumb = function (model) {
var that = {}, priv = {};
......@@ -154,7 +154,7 @@
};
that.updateElementData = function (element_id, data) {
_.extend(priv.element_container[element_id], data);
$.extend(priv.element_container[element_id], data);
priv.onDataChange();
};
......@@ -176,8 +176,8 @@
that.clearAll = function () {
$("[id=render]").children().remove()
_.each(_.pairs(priv.element_container), function(element, index) {
priv.removeElement(element[0]);
$.each(priv.element_container, function(idx, element) {
priv.removeElement(element);
});
};
......@@ -230,15 +230,13 @@
isTarget:true,
//dropOptions : exampleDropOptions
};
_.each(_.pairs(option.anchor), function(value, key, list) {
var anchor = value[0],
endpoint_configuration = value[1];
jsPlumb.addEndpoint(element.id, { anchor: anchor }, endpoint);
})
for (var key in option.anchor) {
jsPlumb.addEndpoint(element.id, { anchor: key }, endpoint);
};
priv.addElementToContainer(element);
};
return that;
};
}(window, jQuery, jsPlumb, console, _));
}(window, jQuery, jsPlumb, console));
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment