Index: /main/trunk/greenstone3/web/interfaces/default/js/debug_scripts.js
===================================================================
--- /main/trunk/greenstone3/web/interfaces/default/js/debug_scripts.js (revision 27012)
+++ /main/trunk/greenstone3/web/interfaces/default/js/debug_scripts.js (revision 27013)
@@ -23,5 +23,5 @@
var _editingDiv;
var _unpauseButton;
- var _closeEditorButtonButton;
+ var _closeEditorButton;
var _xmlStatusBar;
var _saveButton;
@@ -35,4 +35,6 @@
var _currentNamespace;
var _isVisualEditor = true;
+
+ var _styleFunctions = new Array();
var partialPageReload = function()
@@ -70,4 +72,13 @@
}
+ var callStyleFunctions = function()
+ {
+ for(var i = 0; i < _styleFunctions.length; i++)
+ {
+ var sFunction = _styleFunctions[i];
+ sFunction();
+ }
+ }
+
var createDebugDiv = function()
{
@@ -96,10 +107,10 @@
_templateSelector.css({"overflow":"auto", "width":"100%"});
- var pickElementButton = $("");
- pickElementButton.button().click(function()
+ var pickElementButton = $("");
+ pickElementButton.click(function()
{
if(!_debugOn)
{
- pickElementButton.attr("value", "Disable debugging");
+ pickElementButton.button("option", "label", "Disable debugging");
$("a").click(function(e)
{
@@ -110,92 +121,43 @@
else
{
- pickElementButton.attr("value", "Enable debugging");
+ pickElementButton.button("option", "label", "Enable debugging");
$("a").off("click");
clearAll();
- _unpauseButton.attr("disabled", "disabled");
- _unpauseButton.addClass("ui-state-disabled");
+ _unpauseButton.button("option", "disabled", true);
_pauseSelector = false;
_debugOn = false;
}
});
-
- _unpauseButton = $("");
- _unpauseButton.button().click(function()
+ _styleFunctions.push(function(){pickElementButton.button({icons:{primary:"ui-icon-power"}})});
+
+ _unpauseButton = $("");
+ _unpauseButton.click(function()
{
if(_pauseSelector)
{
_pauseSelector = false;
- $(this).attr("disabled", "disabled");
- $(this).addClass("ui-state-disabled");
- }
- });
- _unpauseButton.attr("disabled", "disabled");
- _unpauseButton.addClass("ui-state-disabled");
-
- _closeEditorButton = $("");
- _closeEditorButton.button().click(function()
- {
- if($(this).val() == "Close editor")
- {
- $(this).val("Open editor");
+ _unpauseButton.button("option", "disabled", true);
+ }
+ });
+ _styleFunctions.push(function(){_unpauseButton.button({icons:{primary:"ui-icon-pencil"}, disabled:true})});
+
+ _closeEditorButton = $("");
+ _closeEditorButton.click(function()
+ {
+ if(_closeEditorButton.button("option", "label") == "Close editor")
+ {
+ _closeEditorButton.button("option", "label", "Open editor");
_editingDiv.hide();
}
else
{
- $(this).val("Close editor");
+ _closeEditorButton.button("option", "label", "Close editor");
_editingDiv.show();
}
});
- _closeEditorButton.attr("disabled", "disabled");
- _closeEditorButton.addClass("ui-state-disabled");
-
- _xmlStatusBar = $("");
- _xmlStatusBar.css("padding", "5px");
- _xmlStatusBar.addClass("ui-corner-all");
-
- //Check the XML for errors every 2 seconds
- setInterval(function()
- {
- if(_editor)
- {
- var xmlString = _editor.getValue();
- try
- {
- var xml = $.parseXML('' + xmlString + "");
- }
- catch(error)
- {
- console.log(error);
- _xmlStatusBar.text("XML ERROR! (Mouse over for details)");
- _xmlStatusBar.addClass("ui-state-error");
- _xmlStatusBar.removeClass("ui-state-active");
- _xmlStatusBar.attr("title", error);
- _saveButton.attr("disabled", "disabled");
- _saveButton.addClass("ui-state-disabled");
- _swapEditorButton.attr("disabled", "disabled");
- _swapEditorButton.addClass("ui-state-disabled");
- return;
- }
-
- _xmlStatusBar.text("XML OK!");
- _xmlStatusBar.addClass("ui-state-active");
- _xmlStatusBar.removeClass("ui-state-error");
- _xmlStatusBar.removeAttr("title");
- if(_saveButton.val() == "Save changes")
- {
- _saveButton.removeAttr("disabled");
- _saveButton.removeClass("ui-state-disabled");
- }
- if(_swapEditorButton.val() == "Switch to Visual Editor")
- {
- _swapEditorButton.removeAttr("disabled");
- _swapEditorButton.removeClass("ui-state-disabled");
- }
- }
-
- }, 2000);
-
- _saveButton = $("");
- _saveButton.button().click(function()
+ _styleFunctions.push(function(){_closeEditorButton.button({icons:{primary:"ui-icon-newwin"}, disabled:true})});
+
+ _saveButton = $("");
+ _saveButton.click(function()
{
if(_editor)
@@ -228,7 +190,6 @@
if(_currentMatch && _currentMatch.length > 0){parameters["s1.match"] = _currentMatch;}
- _saveButton.val("Saving...");
- _saveButton.attr("disabled", "disabled");
- _saveButton.addClass("ui-state-default");
+ _saveButton.button("option", "label", "Saving...");
+ _saveButton.button("option", "disabled", true);
$.post(url, parameters)
@@ -246,7 +207,6 @@
.complete(function()
{
- _saveButton.val("Save changes");
- _saveButton.removeAttr("disabled");
- _saveButton.removeClass("ui-state-default");
+ _saveButton.button("option", "label", "Save changes");
+ _saveButton.button("option", "disabled", false);
partialPageReload();
});
@@ -258,8 +218,7 @@
}
});
- _saveButton.attr("disabled", "disabled");
- _saveButton.addClass("ui-state-disabled");
-
- _swapEditorButton = $("");
+ _styleFunctions.push(function(){_saveButton.button({icons:{primary:"ui-icon-disk"}, disabled:true})});
+
+ _swapEditorButton = $("");
_swapEditorButton.button().click(function()
{
@@ -283,5 +242,5 @@
_editor.clearSelection();
_textEditor.show();
- _swapEditorButton.val("Switch to Visual Editor");
+ _swapEditorButton.button("option", "label", "Switch to Visual Editor");
_isVisualEditor = false;
}
@@ -295,12 +254,13 @@
_vEditor.selectRootElement();
_vEditor.getMainDiv().show();
- _swapEditorButton.val("Switch to XML Editor");
+ _swapEditorButton.button("option", "label", "Switch to XML Editor");
_isVisualEditor = true;
}
}
});
-
- undoButton = $("");
- undoButton.button().click(function()
+ _styleFunctions.push(function(){_swapEditorButton.button({icons:{primary:"ui-icon-refresh"}})});
+
+ undoButton = $("");
+ undoButton.click(function()
{
if(_isVisualEditor)
@@ -313,5 +273,48 @@
}
});
-
+ _styleFunctions.push(function(){undoButton.button({icons:{primary:"ui-icon-arrowreturnthick-1-w"}})});
+
+ _xmlStatusBar = $("");
+ _xmlStatusBar.css("padding", "5px");
+ _xmlStatusBar.addClass("ui-corner-all");
+
+ //Check the XML for errors every 2 seconds
+ setInterval(function()
+ {
+ if(_editor)
+ {
+ var xmlString = _editor.getValue();
+ try
+ {
+ var xml = $.parseXML('' + xmlString + "");
+ }
+ catch(error)
+ {
+ console.log(error);
+ _xmlStatusBar.text("XML ERROR! (Mouse over for details)");
+ _xmlStatusBar.addClass("ui-state-error");
+ _xmlStatusBar.removeClass("ui-state-active");
+ _xmlStatusBar.attr("title", error);
+ _saveButton.button("option", "disabled", true);
+ _swapEditorButton.button("option", "disabled", true);
+ return;
+ }
+
+ _xmlStatusBar.text("XML OK!");
+ _xmlStatusBar.addClass("ui-state-active");
+ _xmlStatusBar.removeClass("ui-state-error");
+ _xmlStatusBar.removeAttr("title");
+ if(_saveButton.button("option", "label") == "Save changes")
+ {
+ _saveButton.button("option", "disabled", false);
+ }
+ if(_swapEditorButton.button("option", "label") == "Switch to Visual Editor")
+ {
+ _swapEditorButton.button("option", "disabled", false);
+ }
+ }
+
+ }, 2000);
+
var clear = $("");
clear.css("clear", "both");
@@ -325,5 +328,7 @@
buttonDiv.append(undoButton);
buttonDiv.append(_xmlStatusBar);
-
+
+ _styleFunctions.push(function(){$(".ui-button").css({"margin-right":"0.5em"});});
+
_mainDiv.append(toolBarDiv);
_mainDiv.append(_editingDiv);
@@ -434,7 +439,5 @@
}});
-
- _closeEditorButton.removeAttr("disabled");
- _closeEditorButton.removeClass("ui-state-disabled");
+ _closeEditorButton.button("option", "disabled", true);
})
.error(function()
@@ -461,6 +464,5 @@
{
_pauseSelector = true;
- _unpauseButton.removeAttr("disabled");
- _unpauseButton.removeClass("ui-state-disabled");
+ _unpauseButton.button("option", "disabled", false);
}
});
@@ -602,5 +604,5 @@
$("body").append(_mainDiv);
- $(".ui-button").css({"padding":"0.2em", "margin-right":"0.5em"});
+ callStyleFunctions();
addMouseEventsToDebugElements(debugElems);