Merge remote-tracking branch 'origin/master' into Astro

This commit is contained in:
斟酌 鵬兄 2018-05-15 17:57:14 +08:00
commit f20d0b9773
8 changed files with 38 additions and 354 deletions

View File

@ -9,52 +9,49 @@
var Perf = __import( "System.utils.Perf" ); var Perf = __import( "System.utils.Perf" );
/** @type {System.Cycle} */ /** @type {System.Cycle} */
var Cycle = __import( "System.Cycle" ); var Cycle = __import( "System.Cycle" );
/** @type {Dandelion.IDOMElement} */
var IDOMElement = __import( "Dandelion.IDOMElement" );
/** @type {Dandelion} */ /** @type {Dandelion} */
var Dand = __import( "Dandelion" ); var Dand = __import( "Dandelion" );
/** @type {Dandelion.Swf} */
var Swf = __import( "Dandelion.Swf" );
/** @type {Dandelion.Swf.ExtAPI} */
var ExtAPI = __import( "Dandelion.Swf.ExtAPI" );
var stage var stage, cCallback;
, helperAddress = "/assets/swf/iClipboard.swf"
, helperId
, cCallback
;
/** @type {Components.Mouse.Clipboard.SwfHelperObj */
var clipboardHelper = null;
var init = function () var init = function ()
{ {
if( stage ) return; if( !stage )
stage = Dand.wrapc('ch_obj no_transition no_transition_recursive');
if( Global.IE )
{ {
document.body.appendChild(stage); stage = Dand.wrapc('ch_obj no_transition no_transition_recursive');
Cycle.next( stage.style.width = "20px";
function (){ stage.style.height= "20px";
stage.innerHTML = Swf.create( stage.style.overflow = "hidden";
helperAddress, 20, 20, helperId = Perf.uuid, 'always', 'transparent' stage.style.cursor = "default";
); stage.style.opacity = "0";
stage.style.background = "rgba( 0, 204, 255, 0.5 )";
document.body.appendChild( stage );
IDOMElement( stage ).addEventListener( "Click", function( e )
{
if( document.body.createTextRange )
{
var range = document.body.createTextRange();
range.moveToElementText( stage );
range.select();
} }
); else if( window.getSelection )
{
var sel = window.getSelection();
var range = document.createRange();
range.selectNodeContents( stage );
sel.removeAllRanges();
sel.addRange( range );
}
document.execCommand( "copy" );
stage.style.display = "none";
if( cCallback )
cCallback();
});
} }
else
{
stage.appendChild(
Swf.create(
helperAddress, 20, 20, helperId = Perf.uuid, 'always', 'transparent'
)
);
document.body.appendChild(stage);
}
stage.style.visibility = "hidden";
ExtAPI.init();
}; };
// Using onmouse<action> properties since event needs to be unique. e.g. single handler // Using onmouse<action> properties since event needs to be unique. e.g. single handler
@ -69,47 +66,30 @@
if( trigger() ) if( trigger() )
{ {
Global.IE && (event || (event = e)); Global.IE && (event || (event = e));
stage.style.visibility = "";
stage.style.left = ( e.pageX - 10 ) + "px"; stage.style.left = ( e.pageX - 10 ) + "px";
stage.style.top = ( e.pageY - 10 ) + "px"; stage.style.top = ( e.pageY - 10 ) + "px";
} }
} }
}; };
var setTextToCopy = function (textToCopy) var setTextToCopy = function( _text )
{ {
if( clipboardHelper && clipboardHelper.copy ) stage.innerHTML = _text;
{
clipboardHelper.copy( textToCopy );
if( Global.debug && clipboardHelper.debug ) clipboardHelper.debug();
}
else
{
// This will loop though cycle by cycle until the movie is ready
Cycle.next(function () {
clipboardHelper = Swf( helperId );
setTextToCopy( textToCopy );
});
}
}; };
// Called by swf
var textCopied = function () var textCopied = function ()
{ {
if( cCallback ) cCallback(); if( cCallback ) cCallback();
debug.Info( "[Clipboard] Text copied" ); debug.Info( "[Clipboard] Text copied" );
stage.style.visibility = "hidden";
// Release the focus on swf
clipboardHelper.blur();
document.onmousemove = null; document.onmousemove = null;
}; };
var onMouseOver = function ( callback ) var onMouseOver = function ( callback )
{ {
if( callback == undefined ) return stage.onmouseover; if( callback == undefined ) return stage.onmouseover;
stage.style.display = "block";
stage.onmouseover = callback; stage.onmouseover = callback;
}; };
@ -117,7 +97,6 @@
{ {
if( callback == undefined ) return stage.onmouseout; if( callback == undefined ) return stage.onmouseout;
stage.onmouseout = function () { stage.onmouseout = function () {
stage.style.visibility = "hidden";
this._callback(); this._callback();
}.bind({_callback: callback}); }.bind({_callback: callback});
}; };
@ -127,5 +106,4 @@
ns[ NS_EXPORT ]( EX_FUNC, "capture", capture ); ns[ NS_EXPORT ]( EX_FUNC, "capture", capture );
ns[ NS_EXPORT ]( EX_VAR, "onMouseOver", onMouseOver ); ns[ NS_EXPORT ]( EX_VAR, "onMouseOver", onMouseOver );
ns[ NS_EXPORT ]( EX_VAR, "onMouseOut", onMouseOut ); ns[ NS_EXPORT ]( EX_VAR, "onMouseOut", onMouseOut );
ns[ NS_EXPORT ]( EX_FUNC, "_textCopied", textCopied );
})(); })();

View File

@ -19,7 +19,6 @@
/** @type {Components.Mouse.Clipboard} */ /** @type {Components.Mouse.Clipboard} */
var Clipboard = __import( "Components.Mouse.Clipboard" ); var Clipboard = __import( "Components.Mouse.Clipboard" );
var ContextMenu = function ( target, items, whichButton, menuInsideTarget, overrides ) var ContextMenu = function ( target, items, whichButton, menuInsideTarget, overrides )
{ {
if ( !target.id ) if ( !target.id )
@ -490,6 +489,5 @@
return false; return false;
}; };
ns[ NS_EXPORT ]( EX_CLASS, "ContextMenu", ContextMenu ); ns[ NS_EXPORT ]( EX_CLASS, "ContextMenu", ContextMenu );
})(); })();

View File

@ -1,7 +0,0 @@
#extAPIConsole {
-webkit-transition: all 0s;
-moz-transition: all 0s;
-ms-transition: all 0s;
-o-transition: all 0s;
transition: all 0s;
}

View File

@ -1,44 +0,0 @@
(function(){
var ns = __namespace( "Dandelion.Swf.ExtAPI" );
/** @type {System.Debug} */
var debug = __import( "System.Debug" );
var jsReady = false
, as = 0
, cutConnection = false
, watchDogTime = new Date().getTime()
, watchDogCounter = 0
, lastCount = 0
;
var ExtAPI = function ()
{
// TODO
};
var isReady = function () { return jsReady; };
var init = function ()
{
jsReady = true;
debug.Info( "[ExtAPI] " + new Date().toString() );
};
var watch = function ()
{
if( watchDogCounter - lastCount < 300 )
{
lastCount = watchDogCounter;
}
else
{
cutConnection = true;
debug.Warning( "[ExtAPI] Console Disabled: possible hanging dectected." )
}
watchDogTime = new Date().getTime();
};
ns[ NS_EXPORT ]( EX_FUNC, "init", init );
ns[ NS_EXPORT ]( EX_FUNC, "ready", isReady );
})();

View File

@ -1,56 +0,0 @@
.swf_wrapper {
position: relative;
overflow: hidden;
}
.swf_wrapper > div {
position: relative;
width: 100%;
height: 100%;
}
.swf_inactive {
background: rgba(0, 0, 0, 0.2);
opacity: 1;
}
.swf_inactive:hover {
opacity: 0.6;
}
.swf_inactive > div {
width: 0;
height: 0;
border-top: 3.5em solid transparent;
border-bottom: 3.5em solid transparent;
border-left: 5em solid #FFF;
position: absolute;
left: 50%;
top: 50%;
margin-top: -3.5em;
margin-left: -1.8em;
}
/* title */
.swf_caption {
bottom: 0;
position: absolute;
display: block;
width: 100%;
color: white;
background: rgba(0, 0, 0, 0.8);
padding: 0.2em;
font-size: 2em;
cursor: default;
}
.swf_desc {
font-size: 60%;
}

View File

@ -1,173 +0,0 @@
(function(){
var ns = __namespace( "Dandelion" );
/** @type {System.utils} */
var utils = __import( "System.utils" );
/** @type {System.utils.IKey} */
var IKey = __import( "System.utils.IKey" );
/** @type {System.Policy} */
var Policy = __import( "System.Policy" );
/** @type {System.Debug} */
var Dand = __import( "Dandelion" );
var IE = __import( "System.Global.IE" );
var s_current = {player: false, mask: false, stage: false, listener: false, sid: null};
var Swf = function (movieName)
{
if ( navigator.appName.indexOf("Microsoft") != -1 )
{
return window[movieName];
}
else
{
return document[movieName];
}
};
var realize = function (id)
{
var movieElement = Dand.id('swfWrapper_' + id)
, swf_origin = Dand.wrap('a')
, _src = movieElement.getAttribute("value")
swf_origin.href = _src;
if( Policy.isAllowedOrigin( stf_origin.host ) ) {
swf_origin = "always";
} else {
swf_origin = "never";
}
movieElement.onclick = ( IE ? createMovieIE : createMovie ).bind({
sid: id
, src: _src
, width: movieElement.style.width
, height: movieElement.style.height
, s_stage:movieElement
, origin: swf_origin
});
};
/*
var getCurrentMovie = function (args)
{
if ( window.ExtAPI )
{
return thisMovie( s_current.sid );
}
return null;
};
*/
var createMovieIE = function ()
{
// Remove previous movie if exists
if(s_current.stage)
{
s_current.stage.firstChild.className = "swf_inactive";
s_current.stage.firstChild.innerHTML = s_current.player;
s_current.stage.childNodes[1].style.bottom = "";
s_current.stage.onclick = s_current.listener;
}
this.s_stage.childNodes[1].style.bottom = "-2em";
s_current.sid = "swf_" + this.sid;
s_current.stage = this.s_stage;
s_current.player = this.s_stage.firstChild.innerHTML;
this.s_stage.firstChild.className = "swf_active";
this.s_stage.firstChild.innerHTML = makeStageIE(this.src, this.width, this.height, s_current.sid, this.origin);
// Save event listener
s_current.listener = this.s_stage.onclick;
// disable click event
this.s_stage.onclick = null;
};
var createMovie = function ()
{
// Remove previous movie if exists
if(s_current.stage)
{
s_current.stage.removeChild(s_current.player);
s_current.stage.firstChild.style.bottom = "";
s_current.stage.insertBefore(mask, stage.firstChild);
s_current.stage.onclick = s_current.listener;
}
this.s_stage.childNodes[1].style.bottom = "-2em";
s_current.sid = "swf_" + this.sid;
// Remove mask
(s_current.stage = this.s_stage).removeChild(s_current.mask = this.s_stage.childNodes[0]);
s_current.player = makeStage(this.src, this.width, this.height, s_current.sid, this.origin);
this.s_stage.appendChild(s_current.player);
// Save event listener
s_current.listener = this.s_stage.onclick;
// disable click event
this.s_stage.onclick = null;
};
var makeStage = function (src, width, height, sid, origin, wmode)
{
return Dand.wrapna("embed",
[
new IKey("src", src)
, new IKey("quality", "high")
, new IKey("bgcolor", "#869ca7")
, new IKey("width", width)
, new IKey("height", height)
, new IKey("name", sid)
, new IKey("align", "middle")
, new IKey("wmode", wmode || "direct")
, new IKey("play", "true")
, new IKey("loop", "false")
, new IKey("quality", "high")
, new IKey("allowScriptAccess", origin)
, new IKey("type", "application/x-shockwave-flash")
, new IKey("pluginspage", "http://www.macromedia.com/go/getflashplayer")
]
);
};
var makeStageIE = function (src, width, height, sid, origin, wmode)
{
return Dand.wrape(
Dand.wrapne('object',
[
Dand.wrapna("param", [new IKey("name", "wmode"), new IKey("value", wmode || "direct")])
, Dand.wrapna("param", [new IKey("name", "quality"), new IKey("value", "high")])
, Dand.wrapna("param", [new IKey("name", "movie"), new IKey("value", src)])
, Dand.wrapna("param", [new IKey("name", "bgcolor"), new IKey("value", "#869ca7")])
, Dand.wrapna("param", [new IKey("name", "allowScriptAccess"), new IKey("value", origin)])
]
,
[
new IKey("classid", "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000")
, new IKey("id", sid)
, new IKey("name", sid)
, new IKey("width", width)
, new IKey("height", height)
, new IKey("data", src)
, new IKey("type", "application/x-shockwave-flash")
, new IKey("codebase", "http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab")
]
)
).innerHTML;
};
__static_method( Swf, "create", IE ? makeStageIE : makeStage );
__static_method( Swf, "realize", realize );
ns[ NS_EXPORT ]( EX_CLASS, "Swf", Swf );
})();

View File

@ -1,5 +0,0 @@
/** @constructor */
Dandelion.Swf.ExtAPI = function (){}
/** @type {Function} */
Dandelion.Swf.ExtAPI.ready;

View File

@ -1,7 +0,0 @@
/** @constructor */
Dandelion.Swf = function (){}
/** @type {Function} */
Dandelion.Swf.create;
/** @type {Function} */
Dandelion.Swf.realize;