Skip to content

Commit

Permalink
refs #17757, AMD updates to dojox modules
Browse files Browse the repository at this point in the history
  • Loading branch information
IamFake authored and dylans committed Feb 27, 2014
1 parent ab97418 commit 4ca4694
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 32 deletions.
61 changes: 35 additions & 26 deletions embed/Flash.js
@@ -1,4 +1,13 @@
define(["dojo"], function(dojo) {
define([
"dojo/_base/lang",
"dojo/_base/unload",
"dojo/_base/array",
"dojo/query",
"dojo/has",
"dojo/dom",
"dojo/on",
"dojo/window"
], function(lang,unload,array,query,has,dom,on,win) {

// module:
// dojox/embed/Flash
Expand All @@ -24,7 +33,7 @@ define(["dojo"], function(dojo) {
};

function prep(kwArgs){
kwArgs = dojo.delegate(_baseKwArgs, kwArgs);
kwArgs = lang.delegate(_baseKwArgs, kwArgs);

if(!("path" in kwArgs)){
console.error("dojox.embed.Flash(ctor):: no path reference to a Flash movie was provided.");
Expand All @@ -37,7 +46,7 @@ define(["dojo"], function(dojo) {
return kwArgs;
}

if(dojo.isIE){
if(has('ie')) {
fMarkup = function(kwArgs){
kwArgs = prep(kwArgs);
if(!kwArgs){ return null; }
Expand Down Expand Up @@ -87,15 +96,15 @@ define(["dojo"], function(dojo) {
})();

// attach some cleanup for IE, thanks to deconcept :)
dojo.addOnWindowUnload(function(){
unload.addOnWindowUnload(function(){
console.warn('***************UNLOAD');
var dummy = function(){};
var objs = dojo.query("object").
var objs = query("object").
reverse().
style("display", "none").
forEach(function(i){
for(var p in i){
if((p != "FlashVars") && dojo.isFunction(i[p])){
if((p != "FlashVars") && typeof i[p] == "function"){
try{
i[p] = dummy;
}catch(e){}
Expand Down Expand Up @@ -226,7 +235,7 @@ var __flashArgs = {

// available: Number
// If there is a flash player available, and if so what version.
this.available = dojox.embed.Flash.available;
this.available = fVersion.major;

// minimumVersion: Number
// The minimum version of Flash required to run this movie.
Expand All @@ -244,11 +253,11 @@ var __flashArgs = {
// A reference to the DOMNode that contains this movie.
this.domNode = null;
if(node){
node = dojo.byId(node);
node = dom.byId(node);
}
// setTimeout Fixes #8743 - creating double SWFs
// also allows time for code to attach to onError
setTimeout(dojo.hitch(this, function(){
setTimeout(lang.hitch(this, function(){
if(kwArgs.expressInstall || this.available && this.available >= this.minimumVersion){
if(kwArgs && node){
this.init(kwArgs, node);
Expand All @@ -265,7 +274,7 @@ var __flashArgs = {
}), 100);
};

dojo.extend(Flash, {
lang.extend(Flash, {
onReady: function(/*HTMLObject*/ movie){
// summary:
// Stub function for you to attach to when the movie reference is first
Expand All @@ -292,23 +301,23 @@ var __flashArgs = {
// summary:
// Initialize (i.e. place and load) the movie based on kwArgs.
this.destroy(); // ensure we are clean first.
node = dojo.byId(node || this.domNode);
node = dom.byId(node || this.domNode);
if(!node){ throw new Error("dojox.embed.Flash: no domNode reference has been passed."); }

// vars to help determine load status
var p = 0, testLoaded=false;
this._poller = null; this._pollCount = 0; this._pollMax = 15; this.pollTime = 100;

if(dojox.embed.Flash.initialized){
if(Flash.initialized){

this.id = dojox.embed.Flash.place(kwArgs, node);
this.id = Flash.place(kwArgs, node);
this.domNode = node;

setTimeout(dojo.hitch(this, function(){
setTimeout(lang.hitch(this, function(){
this.movie = this.byId(this.id, kwArgs.doc);
this.onReady(this.movie);

this._poller = setInterval(dojo.hitch(this, function(){
this._poller = setInterval(lang.hitch(this, function(){

// catch errors if not quite ready.
try{
Expand Down Expand Up @@ -345,7 +354,7 @@ var __flashArgs = {
if(!this.movie){ return; }

// remove any proxy functions
var test = dojo.delegate({
var test = lang.delegate({
id: true,
movie: true,
domNode: true,
Expand All @@ -361,7 +370,7 @@ var __flashArgs = {
// poll the movie
if(this._poller){
// wait until onLoad to destroy
dojo.connect(this, "onLoad", this, "_destroy");
on(this, "Load", this, "_destroy");
} else {
this._destroy();
}
Expand Down Expand Up @@ -398,7 +407,7 @@ var __flashArgs = {
});

// expose information through the constructor function itself.
dojo.mixin(Flash, {
lang.mixin(Flash, {
// summary:
// A singleton object used internally to get information
// about the Flash player available in a browser, and
Expand Down Expand Up @@ -445,18 +454,18 @@ var __flashArgs = {
// example:
// Create "setMessage" and "getMessage" methods on foo.
// | var foo = new Flash(args, someNode);
// | dojo.connect(foo, "onLoad", dojo.hitch(foo, function(){
// | dojo.connect(foo, "onLoad", lang.hitch(foo, function(){
// | Flash.proxy(this, [ "setMessage", "getMessage" ]);
// | this.setMessage("Flash.proxy is pretty cool...");
// | console.log(this.getMessage());
// | }));
dojo.forEach((dojo.isArray(methods) ? methods : [ methods ]), function(item){
this[item] = dojo.hitch(this, function(){
array.forEach((methods instanceof Array ? methods : [ methods ]), function(item){
this[item] = lang.hitch(this, function(){
return (function(){
return eval(this.movie.CallFunction(
'<invoke name="' + item + '" returntype="javascript">'
+ '<arguments>'
+ dojo.map(arguments, function(item){
+ array.map(arguments, function(item){
// FIXME:
// investigate if __flash__toXML will
// accept direct application via map()
Expand All @@ -475,11 +484,11 @@ var __flashArgs = {

Flash.place = function(kwArgs, node){
var o = fMarkup(kwArgs);
node = dojo.byId(node);
node = dom.byId(node);
if(!node){
node = dojo.doc.createElement("div");
node = win.doc.createElement("div");
node.id = o.id+"-container";
dojo.body().appendChild(node);
win.body().appendChild(node);
}
if(o){
node.innerHTML = o.markup;
Expand All @@ -489,7 +498,7 @@ var __flashArgs = {
}
Flash.onInitialize();

dojo.setObject("dojox.embed.Flash", Flash);
lang.setObject("dojox.embed.Flash", Flash);

return Flash;
});
2 changes: 1 addition & 1 deletion form/Uploader.js
Expand Up @@ -273,7 +273,7 @@ define([
//
delete this._files;
this._disconnectButton();
array.forEach(this._inputs, domConstruct.destroy, dojo);
array.forEach(this._inputs, domConstruct.destroy);
this._inputs = [];
this._nameIndex = 0;
this._createInput();
Expand Down
10 changes: 5 additions & 5 deletions widget/ColorPicker.js
Expand Up @@ -97,15 +97,15 @@ define([
// to cause the points to adjust and the values to reflect the current color.
value: "#ffffff",

_underlay: kernel.moduleUrl("dojox.widget","ColorPicker/images/underlay.png"),
_underlay: require.toUrl("dojox/widget/ColorPicker/images/underlay.png"),

_hueUnderlay: kernel.moduleUrl("dojox.widget","ColorPicker/images/hue.png"),
_hueUnderlay: require.toUrl("dojox/widget/ColorPicker/images/hue.png"),

_pickerPointer: kernel.moduleUrl("dojox.widget","ColorPicker/images/pickerPointer.png"),
_pickerPointer: require.toUrl("dojox/widget/ColorPicker/images/pickerPointer.png"),

_huePickerPointer: kernel.moduleUrl("dojox.widget","ColorPicker/images/hueHandle.png"),
_huePickerPointer: require.toUrl("dojox/widget/ColorPicker/images/hueHandle.png"),

_huePickerPointerAlly: kernel.moduleUrl("dojox.widget","ColorPicker/images/hueHandleA11y.png"),
_huePickerPointerAlly: require.toUrl("dojox/widget/ColorPicker/images/hueHandleA11y.png"),

templateString: template,

Expand Down

0 comments on commit 4ca4694

Please sign in to comment.