';
+ }
+ else
+ {
+ output_string += ' | ';
+ }
+ output_string += '' + options.label + ' : | ';
+ output_string += '' + displayDataType(value, options, name, key) + ' | ';
+ output_string += '';
+ $(id).append(output_string);
+ if (options.optional == 'true') {
+ $("#opt_"+ name).on("click", function () {
+ var this_name = name;
+ removeOptionalProperty(this_name);
+ });
+ }
+ }
+ },
+
+
+ removeOptionalProperty = function (name) {
+ console.log("Handler for removing optional properties called: " + name);
+
+ // Need to remove row from the screen and
+ // Also need to remove property from the data store
+ },
+
+
+ convertTextAreas = function ()
+ {
+ $.each(textareas_options, function (i, options) {
+ var ckoptions = {};
+
+ if (options.options.height)
+ {
+ var height = parseInt(options.options.height) + 20;
+ ckoptions['height'] = height;
+ }
+ if (options.options.type == 'script')
+ {
+ // enable source mode of ckeditor
+ }
+ $('#'+options.id).ckeditor(function(){
+ // Editor is ready, attach onblur event
+ this.on('blur', function(){
+ // This is the call back when editor looses focus
+ if (this.checkDirty())
+ {
+ inputChanged(options.id, options.key, options.name, this.getData());
+ }
+ })
+ }, ckoptions);
+ });
+ },
+
+
+ convertTextInputs = function ()
+ {
+ $.each(textinputs_options, function (i, options) {
+ $('div.inputtext').ckeditor(function(){
+ // Editor is ready, attach onblur event
+ this.on('blur', function(){
+ // This is the call back when editor looses focus
+ if (this.checkDirty())
+ { var thisValue = this.getData();
+ thisValue = thisValue.substr(0, thisValue.length-1); // Remove the extra linebreak
+ inputChanged(options.id, options.key, options.name, thisValue);
+ }
+ })
+ }, { toolbarGroups : [
+ { name: 'basicstyles', groups: [ 'basicstyles' ] },
+ { name: 'colors' }]
+ });
+ });
+ },
+
+
+ convertColorPickers = function ()
+ {
+ $.each(colorpickers, function (i, options){
+ var myPicker = new jscolor.color(document.getElementById(options.id), {})
+ myPicker.fromString(options.value) // now you can access API via 'myPicker' variable
+
+ });
+ },
+
+ setAttributeValue = function (key, name, value)
+ {
+ var attributes = lo_data[key]['attributes'];
+ // Get the node name
+ var node_name = '';var i=attributes.length;
+ for(var i=0; i< attributes.length; i++)
+ {
+ if (attributes[i].name == 'nodeName')
+ {
+ node_name = attributes[i].value;
+ break;
+ }
+ }
+
+ var node_options = wizard_data[node_name].node_options;
+
+ if (node_options['cdata'] && node_options['cdata_name'] == name)
+ {
+ lo_data[key]['data'] = value;
+ }
+ else
+ {
+ var attr_found = false;
+
+ // find the value
+ for (var j=0; !attr_found && j= 0)
+ {
+ value = (valuePassed) ? passedValue : $('#' + id).html();
+ value = value.substr(3);
+ value = value.substr(0, value.length-4);
+ value.trim();
+ }
+ else
+ {
+ value = $('#' + id).val();
+ }
+
+ if (id.indexOf('color')>=0)
+ {
+ value = value.substr(1);
+ value = '0x' + value;
+ }
+ setAttributeValue(key, name, value);
+ },
+
+
+ displayDataType = function (value, options, name, key) {
+ var html; //console.log(options);
+
+ switch(options.type.toLowerCase())
+ {
+ case 'checkbox':
+ var id = 'checkbox_' + form_id_offset;
+ form_id_offset++;
+ html = '';
+ break;
+ case 'combobox':
+ var id = 'select_' + form_id_offset;
+ form_id_offset++;
+ var s_options = options.options.split(',');
+ var s_data = [];
+ if (options.data)
+ {
+ s_data = options.data.split(',');
+ }
+ html = '';
+ break;
+ case 'text':
+ case 'script':
+ case 'html':
+ case 'textarea':
+ var id = "textarea_" + form_id_offset;
+ form_id_offset++;
+ html = "";
+ textareas_options.push({id: id, key: key, name: name, options: options});
+ break;
+ case 'numericstepper':
+ var min = parseInt(options.min);
+ var max = parseInt(options.max);
+ var step = parseInt(options.step);
+ var intvalue = parseInt(value);
+ //console.log({min: min, max: max, step: step});
+ if (!Modernizr.inputtypes.number)
+ {
+ var id = 'select_' + form_id_offset;
+ form_id_offset++;
+ html = '";
+ }
+ else
+ {
+ var id = 'numericstepper_' + form_id_offset;
+ form_id_offset++;
+ html = '';
+ }
+ break;
+ case 'pagelist':
+ // Implement differently then in the flash editor
+ // Leave PageIDs untouched, and prefer to use the PageID over the linkID
+ var id = 'select_' + form_id_offset;
+ form_id_offset++;
+ html = '";
+ break;
+ case 'colourpicker':
+ var colorvalue = value;
+ var id = 'colorpicker_' + form_id_offset;
+ form_id_offset++;
+ if (colorvalue.indexOf("0x") == 0)
+ {
+ colorvalue ='#' + colorvalue.substr(2);
+ }
+ if (Modernizr.inputtypes.color)
+ {
+ html = '';
+ }
+ else
+ {
+ html = '';
+ colorpickers.push({id: id, value: colorvalue, options: options});
+ }
+ break;
+ case 'hotspot':
+ case 'drawing':
+ case 'languagelist':
+ case 'datefield':
+ case 'datagrid':
+ case 'webpage':
+ case 'media':
+ default:
+
+ //html = "";
+ var id = 'textinput_' + form_id_offset;
+ form_id_offset++;
+ html = "";
+ textinputs_options.push({id: id, key: key, name: name, options: options});
+ }
+ return html;
+ };
+
+ // Add the functions that need to be public
+ my.build_lo_data = build_lo_data;
+ my.create_insert_page_menu = create_insert_page_menu;
+ my.getAttributeValue = getAttributeValue;
+ my.displayParameter = displayParameter;
+ my.convertTextAreas = convertTextAreas;
+ my.convertTextInputs = convertTextInputs;
+ my.convertColorPickers = convertColorPickers;
+
+ return parent;
+
+})(jQuery, EDITOR || {});
+
diff --git a/editor/js/tree.js b/editor/js/tree.js
new file mode 100644
index 0000000000..224c8aee84
--- /dev/null
+++ b/editor/js/tree.js
@@ -0,0 +1,370 @@
+// Tree : Add the tree object to the editor
+var EDITOR = (function ($, parent) {
+
+ // Create the tree object and refer locally to it as 'my'
+ var my = parent.tree = {},
+ toolbox = parent.toolbox,
+
+ // Called once document is ready
+ setup = function () {
+ do_bottom_buttons();
+ },
+
+ // Add the buttons
+ do_buttons = function () {
+ $( "#insert-dialog" ).hide();
+ $( "#insert-buttons" ).hide();
+
+ var insert_page = function() {
+ $( "#insert-dialog" ).dialog({ width: '60%' });
+ },
+
+ delete_page = function() {
+ deleteSelectedNodes();
+ },
+
+ duplicate_page = function() {
+ duplicateSelectedNodes();
+ },
+
+ buttons = $('').attr('id', 'top_buttons');
+ $([
+ {name:'Insert', icon:'editor/img/insert.png', id:'insert_button', click:insert_page},
+ {name:'Copy', icon:'editor/img/copy.png', id:'copy_button', click:duplicate_page},
+ {name:'Delete', icon:'editor/img/delete.gif', id:'delete_button', click:delete_page}
+ ])
+ .each(function(index, value) {
+ var button = $('