Testing Cloud9 Wizard Plugin's behavior with ui.insertHtml method using an HTML file.
Last active
August 29, 2015 14:24
-
-
Save serkanserttop/e083c6b41ba56b30016d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "test.wizard.require", | |
"description": "", | |
"version": "0.0.1", | |
"author": "", | |
"contributors": [{ | |
"name": "", | |
"email": "" | |
}], | |
"repository": { | |
"type": "git", | |
"url": "" | |
}, | |
"plugins": { | |
"test.wizard.require": {} | |
}, | |
"categories": ["miscellaneous"], | |
"licenses": [] | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div id="test.wizard.require.container"> | |
<p>This is test.wizard.require.container</p> | |
<div id="test.wizard.require.form.container"> | |
<p>This is test.wizard.require.form.container</p> | |
</div> | |
</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define(function(require, exports, module) { | |
main.consumes = ["Wizard", "WizardPage", "ui", "commands", "menus", "Form"]; | |
main.provides = ["test.wizard.require"]; | |
return main; | |
function waitForElementById(id, callback, duration) { | |
duration = duration || 100; | |
var tid = setInterval(function() { | |
var elem = document.getElementById(id); | |
if (elem) { | |
clearInterval(tid); | |
callback(); | |
} | |
}, duration); | |
} | |
function main(options, imports, register) { | |
var Wizard = imports.Wizard; | |
var WizardPage = imports.WizardPage; | |
var ui = imports.ui; | |
var menus = imports.menus; | |
var commands = imports.commands; | |
var Form = imports.Form; | |
/***** Initialization *****/ | |
var plugin = new Wizard("Ajax.org", main.consumes, { | |
title: "Wizard Require Test", | |
allowClose: true, | |
height: 400 | |
}); | |
var markup = require("text!./step1.html"); | |
var FORM_WRAPPER_DIV_ID = 'test.wizard.require.form.container'; | |
plugin.on("draw", function() { | |
var step1 = new WizardPage({ | |
name: "step1" | |
}, plugin); | |
step1.on("draw", function(e) { | |
ui.insertHtml(e.html, markup, step1); | |
waitForElementById(FORM_WRAPPER_DIV_ID, addFormIntoStep1) | |
}); | |
plugin.startPage = step1; | |
}); | |
/***** Functions *****/ | |
function addFormIntoStep1() { | |
//Taken from | |
var form = new Form({ | |
html: document.getElementById(FORM_WRAPPER_DIV_ID), | |
edge: "10 10 10 10", | |
className: "my-form", | |
style: "background: #EEE", | |
colwidth: 300, | |
form: [{ | |
title: "Username", | |
name: "username", | |
type: "textbox", | |
}, { | |
title: "Password", | |
name: "password", | |
type: "password", | |
}, { | |
name: "loginfail", | |
type: "label", | |
caption: "Could not login. Please try again.", | |
style: "color:rgb(255, 143, 0);margin-left:5px;" | |
}] | |
}); | |
} | |
function load() { | |
commands.addCommand({ | |
name: "test.wizard.require", | |
isAvailable: function() { | |
return true; | |
}, | |
exec: function() { | |
plugin.show(); | |
} | |
}, plugin); | |
menus.addItemByPath("Tools/Test Wizard Require", new ui.item({ | |
command: "test.wizard.require" | |
}), 300, plugin); | |
} | |
function start() { | |
} | |
function abort() { | |
} | |
/***** Lifecycle *****/ | |
plugin.on("load", function() { | |
load(); | |
}); | |
plugin.on("unload", function() { | |
}); | |
/***** Register and define API *****/ | |
/** | |
* Your wizard description | |
**/ | |
plugin.freezePublicAPI({ | |
}); | |
register(null, { | |
"test.wizard.require": plugin | |
}); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment