Initial commit

This commit is contained in:
2015-08-14 18:12:10 +08:00
parent f19f612fad
commit 4c93896df3
93 changed files with 4724 additions and 0 deletions

View File

@@ -0,0 +1,3 @@
.motion_block {
display: inline-block;
}

View File

@@ -0,0 +1,158 @@
(function(){
var ns = __namespace( "Dandelion.CSSAnimations" );
/** @type {System.utils.EventKey} */
var EventKey = __import( "System.utils.EventKey" );
/** @type {System.Cycle.Trigger} */
var Trigger = __import( "System.Cycle.Trigger" );
/** @type {Dandelion} */
var Dand = __import( "Dandelion" );
/** @type {Dandelion.IDOMElement} */
var IDOMElement = __import( "Dandelion.IDOMElement" );
var MovieClip = function (
__target
, __row, __col
, __width, __height
, frame, start
)
{
if( frame == __row * __col ) frame = 0;
var canvas = Dand.wrapc( "motion_block no_transition" )
, r = __row - 1
, c = __col - 1
, w = __width
, h = __height
, i = 0, j = 0
, k = 0, l = frame - 1
;
var _next, _prev, _goto;
if( frame )
{
_next = function ()
{
( c < ++ i ) && ( ( i = 0 ) || ( ( r < ++ j ) && ( j = 0 ) ) );
( l < ++ k ) && ( i = j = k = 0 );
};
_prev = function ()
{
( -- k < 0 ) && ( k = l );
_goto( k );
};
_goto = function ( f )
{
for ( i = j = k = 0; 0 < f; f -- ) _next();
};
}
else
{
_next = function ()
{
( c < ++ i ) && ( ( i = 0 ) || ( ( r < ++ j ) && ( j = 0 ) ) );
};
_prev = function ()
{
( -- i < 0 ) && ( ( i = c ) && ( ( -- j < 0 ) && ( j = r ) ) );
};
_goto = function ( f )
{
for ( i = j = k = 0; k < f; k ++ ) _next();
};
}
canvas.style.backgroundImage = "url(" + __target + ")";
canvas.style.width = w + "px";
canvas.style.height = h + "px";
canvas.style.backgroundPosition = "0px 0px";
var updateCanvas = function()
{
canvas.style.backgroundPosition = ( -i * w ) + "px " + ( -j * h ) + "px";
};
// At 0 position
var at0 = function() { return ( i == 0 && j == 0 ) };
var obj = {
_next: function() { _next(); updateCanvas(); return at0(); }
, _prev: function() { _prev(); updateCanvas(); return at0(); }
, _goto: function( n ) { _goto( n ); updateCanvas(); }
};
this["stage"] = canvas;
this["nextFrame"] = this.nextFrame.bind( obj );
this["prevFrame"] = this.prevFrame.bind( obj );
this["gotoFrame"] = this.gotoFrame.bind( obj );
};
MovieClip.prototype.nextFrame = function ()
{
return this._next();
};
MovieClip.prototype.prevFrame = function ()
{
return this._prev();
};
MovieClip.prototype.gotoFrame = function ( frameNumber )
{
return this._goto( frameNumber );
};
MovieClip.prototype.stage = null;
/** @param {Dandelion.CSSAnimations.MovieClip} mc
* @param {Boolean} whenStatic
*/
var MouseOverMovie = function ( mc, whenStatic )
{
if ( mc instanceof MovieClip )
{
var canRegister = true;
var terminate = false;
var registrar = function () { return mc.nextFrame() || terminate; };
var handler = function ()
{
mc.gotoFrame( whenStatic );
canRegister = true;
terminate = false;
};
var mouseOverHandler = function ( e )
{
if( canRegister )
{
canRegister = false;
mc.gotoFrame(0);
Trigger.register( registrar, handler, 33 );
}
};
var mouseOutHandler = function ( e )
{
if( !canRegister )
terminate = true;
};
mc.gotoFrame( whenStatic );
IDOMElement( mc.stage ).addEventListeners([
new EventKey( "MouseOver", mouseOverHandler )
, new EventKey( "MouseOut", mouseOutHandler )
]);
}
};
ns[ NS_EXPORT ]( EX_CLASS, "MovieClip", MovieClip );
ns[ NS_EXPORT ]( EX_FUNC, "MouseOverMovie", MouseOverMovie );
})();

View File

@@ -0,0 +1,41 @@
.comp, .compx * {
-webkit-transition: all .25s ease-out;
-moz-transition: all .25s ease-out;
-o-transition: all .25s ease-out;
transition: all .25s ease-out;
}
.rcomp, .rcompx * {
-webkit-transition: none;
-moz-transition: none;
-o-transition: none;
transition: none;
}
.cubic500 {
-webkit-transition: all 500ms cubic-bezier(0.215, 0.610, 0.355, 1.000);
-moz-transition: all 500ms cubic-bezier(0.215, 0.610, 0.355, 1.000);
-ms-transition: all 500ms cubic-bezier(0.215, 0.610, 0.355, 1.000);
-o-transition: all 500ms cubic-bezier(0.215, 0.610, 0.355, 1.000);
transition: all 500ms cubic-bezier(0.215, 0.610, 0.355, 1.000); /* easeOutCubic */
-webkit-transition-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000);
-moz-transition-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000);
-ms-transition-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000);
-o-transition-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000);
transition-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000); /* easeOutCubic */
}
.cubic200 {
-webkit-transition: all 200ms cubic-bezier(0.215, 0.610, 0.355, 1.000);
-moz-transition: all 200ms cubic-bezier(0.215, 0.610, 0.355, 1.000);
-ms-transition: all 200ms cubic-bezier(0.215, 0.610, 0.355, 1.000);
-o-transition: all 200ms cubic-bezier(0.215, 0.610, 0.355, 1.000);
transition: all 200ms cubic-bezier(0.215, 0.610, 0.355, 1.000); /* easeOutCubic */
-webkit-transition-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000);
-moz-transition-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000);
-ms-transition-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000);
-o-transition-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000);
transition-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000); /* easeOutCubic */
}

View File

@@ -0,0 +1,5 @@
/*
(function(){
var ns = __namespace( "Dandelion.CSSAnimations" );
})();
*/

View File

@@ -0,0 +1,43 @@
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed,
figure, figcaption, footer, header, hgroup,
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
font: inherit;
vertical-align: baseline;
}
sup, sub {
vertical-align: baseline;
font-size: 80%;
}
article, aside, details, figcaption, figure,
footer, header, hgroup, menu, nav, section {
display: block;
}
ol, ul {
list-style: none;
}
blockquote, q {
quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
content: '';
content: none;
}
table {
border-collapse: collapse;
border-spacing: 0;
}

View File

@@ -0,0 +1,5 @@
/*
(function(){
var ns = __namespace( "Dandelion.CSSReset" );
})();
*/

View File

@@ -0,0 +1,199 @@
(function(){
var ns = __namespace( "Dandelion" );
/** @type {System.utils.IKey} */
var IKey = __import( "System.utils.IKey" );
/** @type {System.utils.Perf} */
var Perf = __import( "System.utils.Perf" );
var wrap = ns[ NS_INVOKE ]( "wrap" );
var IDOMObject = ns[ NS_INVOKE ]( "IDOMObject" );
// IDOMElement, augmented element wrapper utilizing IKeys
var IDOMElement = function (element, sw)
{
if (element instanceof IDOMElement) return element;
if (sw)
{
IDOMObject.call( this, element, true );
this["getDAttribute"] = this.getDAttribute.bind(element);
this["lootChildren"] = this.lootChildren.bind(element);
this["foreach"] = this.foreach.bind(element);
this["reverseChild"] = this.reverseChild.bind(element);
this["first"] = this.first.bind(element);
this["last"] = this.last.bind(element);
this["contains"] = this.contains.bind(element);
// Org values
this["style"] = element.style;
this["hasAttribute"] = function ( key ) { this.hasAttribute( key ); }.bind( element );
this["removeAttribute"] = function ( key ) { this.removeAttribute( key ); }.bind( element );
this["element"] = element;
// Overrides
this["setAttribute"] = this.setAttribute.bind( element );
}
else if ( element && element[ "nodeType" ] != undefined && element.nodeType == 1 )
{
return new IDOMElement( element, true );
}
else if( element === undefined )
{
return new IDOMElement( wrap(), true );
}
else
{
throw new Error( "[Dandelion.IDOMElement] Invalid argument" );
}
return this;
};
__extends( IDOMElement, IDOMObject );
IDOMElement.prototype.setAttribute = function( k, v )
{
if( k instanceof IKey )
{
this.setAttribute( k.keyName, k.keyValue );
}
else if( k instanceof Array )
{
for ( var i in k )
{
if ( k[i] instanceof IKey )
{
this.setAttribute( k[i].keyName, k[i].keyValue );
}
}
}
else
{
this.setAttribute( k, v );
}
};
IDOMElement.prototype.lootChildren = function ( element )
{
var _nodes = element.childNodes;
while(_nodes.length)
{
this.appendChild( element.removeChild( _nodes[0] ) );
}
};
IDOMElement.prototype.getDAttribute = function(name)
{
var i = this.getAttribute("data-" + name);
return i && decodeURIComponent(i);
};
IDOMElement.prototype.foreach = function(type, callback)
{
var c = Array.apply( [], this.childNodes ), l = c.length;
for(var i = 0; i < l; i ++)
{
if (c[i].nodeType == type)
{
callback(c[i], this);
}
}
};
var matchNone = function() { return false; };
var matchType = function( c, t ) { return c.nodeType == t; };
var matchName = function( c, t ) { return c.nodeName == t; };
var getMatch = function( type )
{
type = typeof( type );
if( type == "number" ) return matchType;
else if( type == "string" ) return matchName;
return matchNone;
};
IDOMElement.prototype.first = function ( type, callback )
{
var c = this.childNodes;
var l = c.length;
var elem = null;
var tc = getMatch( type );
for( var i = 0; i < l; i ++ )
{
if ( tc( c[i], type ) )
{
if( callback === undefined || callback( c[i], this ) )
{
elem = c[i];
break;
}
}
}
return elem;
};
IDOMElement.prototype.last = function ( type, callback )
{
var c = this.childNodes;
var l = c.length - 1;
var elem = null;
var tc = getMatch( type );
for( var i = l; -1 < i ; i -- )
{
if ( tc( c[i], type ) )
{
if( callback === undefined || callback( c[i], this ) )
{
elem = c[i];
break;
}
}
}
return elem;
};
IDOMElement.prototype.contains = function ( target )
{
if( target.parentElement )
{
if( target == this )
{
return true;
}
return this.contains( target.parentElement );
}
return false;
};
// attribute keys
IDOMElement.prototype.aKeys = function()
{
var ikeys = [];
var attrs = this.element.attributes;
var l = attrs.length;
for( var i = 0; i < l; i ++ )
{
ikeys.push( new IKey( attrs[i].name, attrs[i].value ) );
}
return ikeys;
};
IDOMElement.prototype.reverseChild = function()
{
var l = this.childNodes.length - 1;
while( -1 < -- l )
{
this.appendChild( this.childNodes[l] );
}
};
ns[ NS_EXPORT ]( EX_CLASS, "IDOMElement", IDOMElement );
})();

View File

@@ -0,0 +1,149 @@
(function(){
var ns = __namespace( "Dandelion" );
/** @type {System.utils.EventKey} */
var EventKey = __import( "System.utils.EventKey" );
var EvtsArr = function () { Array.call( this ); };
/** @param {System.utils.EventKey} e */
EvtsArr.prototype.indexOf = function( e )
{
var l = this.length;
for( var i = 0; i < l; i ++ )
{
/** @type {System.utils.EventKey} */
var evt = this[i];
if( evt.type == e.type && evt.handler == e.handler )
{
return i;
}
}
return -1;
};
__extends( EvtsArr, Array );
var IDOMObject = function ( obj, sw )
{
if ( obj instanceof IDOMObject ) return obj;
if ( sw )
{
this["addEventListener"] = this.addEventListener.bind(obj);
this["addEventListeners"] = this.addEventListeners.bind(this);
this["hasListener"] = this.hasListener.bind(obj);
this["removeEventListener"] = this.removeEventListener.bind(obj);
}
else if ( obj )
{
return new IDOMObject( obj, true );
}
else
{
throw new Error( "[Dandelion.IDOMObject] Invalid argument" );
}
}
IDOMObject.prototype.hasListener = function(e)
{
if( e instanceof EventKey
&& this._events
&& this._events.indexOf(e) != -1
)
{
return this._events[ this._events.indexOf(e) ];
}
return null;
};
IDOMObject.prototype.addEventListener = function (event, handler)
{
var e;
if (typeof event == "string" && handler)
{
e = new EventKey(event, handler);
}
else if (event instanceof EventKey)
{
e = event;
}
else
{
return false;
}
if ( this._events )
{
if ( this._events.indexOf( e ) < 0 )
{
this._events.push( e );
}
else
{
return false;
}
}
else
{
this._events = new EvtsArr();
this._events[0] = e;
}
if( this.addEventListener )
{
this.addEventListener( e.type, e.handler, false );
}
// IE
else if( this.attachEvent )
{
this.attachEvent('on' + e.type, e.handler);
}
else
{
this['on' + e.type] = e.handler;
}
return true;
};
IDOMObject.prototype.addEventListeners = function(evtKeys)
{
if(evtKeys instanceof Array)
{
for (var i in evtKeys)
{
this.addEventListener(evtKeys[i]);
}
}
};
IDOMObject.prototype.removeEventListener = function( e, handler )
{
if( handler )
{
e = new EventKey( e, handler );
}
if( this._events )
{
delete this._events[ this._events.indexOf(e) ];
}
if( this.removeEventListener )
{
this.removeEventListener( e.type, e.handler );
}
// IE
else if( this.detachEvent )
{
this.detachEvent( 'on' + e.type, e.handler );
}
else
{
this['on' + e.type] = null;
}
};
ns[ NS_EXPORT ]( EX_CLASS, "IDOMObject", IDOMObject );
})();

View File

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

View File

@@ -0,0 +1,44 @@
(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

@@ -0,0 +1,56 @@
.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

@@ -0,0 +1,173 @@
(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

@@ -0,0 +1,10 @@
(function(){
var ns = __namespace( "Dandelion.Window" );
ns[ NS_EXPORT ]( EX_READONLY_GETTER , "scrollTop" , function() { return window.pageYOffset || document.documentElement.scrollTop; } );
ns[ NS_EXPORT ]( EX_READONLY_GETTER , "scrollLeft" , function() { return window.pageXOffset || document.documentElement.scrollLeft; } );
ns[ NS_EXPORT ]( EX_READONLY_GETTER , "scrollHeight" , function() { return window.scrollHeight || document.documentElement.scrollHeight } );
ns[ NS_EXPORT ]( EX_READONLY_GETTER , "clientHeight" , function() { return window.clientHeight || document.documentElement.clientHeight; } );
ns[ NS_EXPORT ]( EX_READONLY_GETTER , "scrollWidth" , function() { return window.scrollWidth || document.documentElement.scrollWidth } );
ns[ NS_EXPORT ]( EX_READONLY_GETTER , "clientWidth" , function() { return window.clientWidth || document.documentElement.clientWidth; } );
})();

View File

@@ -0,0 +1,187 @@
(function(){
var ns = __namespace( "Dandelion" );
var IE = __import( "System.Global.IE" );
/* @type {System.utils.IKey}*/
var IKey = __import( "System.utils.IKey" );
/* @type {Dandelion.IDOMElement}*/
var IDOMElement;
var wrap = function ( wwith, id, wclass, elements, iKeys )
{
var tmp = document.createElement( wwith || "div" );
if( id ) tmp.id = id;
if( wclass )
{
if( IE )
{
tmp.className = wclass;
}
else
{
tmp.setAttribute( "class", wclass );
}
}
if ( iKeys )
{
if ( iKeys instanceof Array )
{
for (var i in iKeys)
{
tmp.setAttribute( iKeys[i].keyName, iKeys[i].keyValue );
}
}
else if ( iKeys instanceof IKey )
{
tmp.setAttribute( iKeys.keyName, iKeys.keyValue );
}
}
if( elements )
{
// is array?
if(elements instanceof Array)
{
var l = elements.length;
for( var i = 0; i < l; i ++ )
{
elements[i] && tmp.appendChild( elements[i] );
}
}
// else if string
else if( typeof elements == "string" )
{
tmp.appendChild(_createTextNode(elements));
}
// else append child, do not do any error handling!
else if( elements )
{
tmp.appendChild( elements );
}
}
return tmp;
};
var wrapc = function ( aClass, elements, iKeys ) {
return wrap( false, false, aClass, elements, iKeys );
};
// wrap element afters
var wrape = function ( elements, iKeys ) {
return wrap( false, false, false, elements, iKeys );
};
// wrap name element after
var wrapne = function ( name, elements, iKeys ) {
return wrap(name, false, false, elements, iKeys);
};
// wrap name attirbutes after
var wrapna = function ( name, iKeys ) {
return wrap(name, false, false, false, iKeys);
};
var _createTextNode = function (s)
{
return document.createTextNode(s);
};
// Bubble up element if <condition>
var bubbleUp = function ( elem, condition )
{
if( condition( elem ) ) return elem;
return elem.parentNode && bubbleUp( elem.parentNode, condition );
};
var chainUpApply = function( elem, func )
{
if( !elem ) return;
var chain = func( elem );
if( chain && elem.parentNode )
{
chainUpApply( elem.parentNode, func );
}
};
var id = function( name, idom )
{
var elem = document.getElementById( name );
if( !elem ) return elem;
if( idom && runtimeImport() )
{
return IDOMElement( elem );
}
return elem;
};
var elements = function( elem, idom )
{
if( idom && runtimeImport() )
{
var l = elem.length;
var ielem = [];
for( var i = 0; i < l; i ++ )
{
ielem[i] = IDOMElement( elem[i] );
}
return ielem;
}
return elem;
};
var tag = function( name, idom, target )
{
target = target === undefined ? document : target;
var elem = target.getElementsByTagName( name );
return elements( elem, idom );
};
var name = function( name, idom, target )
{
target = target === undefined ? document : target;
var elem = target.getElementsByName( name );
return elements( elem, idom );
};
var getClass = function( name, idom, target )
{
target = target === undefined ? document : target;
var elem = target.getElementsByClassName( name );
return elements( elem, idom );
};
var runtimeImport = function()
{
if( IDOMElement ) return true;
try
{
var a = "Dandelion.IDOMElement";
IDOMElement = __import( a );
return true;
}
catch( e ) { }
return false;
};
ns[ NS_EXPORT ]( EX_FUNC, "wrap", wrap );
ns[ NS_EXPORT ]( EX_FUNC, "wrapc", wrapc );
ns[ NS_EXPORT ]( EX_FUNC, "wrape", wrape );
ns[ NS_EXPORT ]( EX_FUNC, "wrapne", wrapne );
ns[ NS_EXPORT ]( EX_FUNC, "wrapna", wrapna );
ns[ NS_EXPORT ]( EX_FUNC, "textNode", _createTextNode );
ns[ NS_EXPORT ]( EX_FUNC, "bubbleUp", bubbleUp );
ns[ NS_EXPORT ]( EX_FUNC, "chainUpApply", chainUpApply );
ns[ NS_EXPORT ]( EX_FUNC, "id", id );
ns[ NS_EXPORT ]( EX_FUNC, "tag", tag );
ns[ NS_EXPORT ]( EX_FUNC, "name", name );
ns[ NS_EXPORT ]( EX_FUNC, "glass", getClass );
})();