Skip to content
This repository has been archived by the owner on Oct 21, 2022. It is now read-only.

Commit

Permalink
If I knew what I were doing as a professional developer, this would b…
Browse files Browse the repository at this point in the history
…e a point release.
  • Loading branch information
Wilto committed Jan 28, 2013
1 parent ac7676b commit fb0f02a
Showing 1 changed file with 54 additions and 54 deletions.
108 changes: 54 additions & 54 deletions src/X-rayHTML.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,74 +23,74 @@
defaultReveal: "inline"
},
methods = {
_create: function() {
return $( this ).each(function() {
var init = $( this ).data( "init." + pluginName );
_create: function() {
return $( this ).each(function() {
var init = $( this ).data( "init." + pluginName );

if( init ) {
return false;
}

$( this )
.data( "init." + pluginName, true )
[ pluginName ]( "_init" )
.trigger( "create." + pluginName );
});
},
_init: function() {
var method = $( this ).data( pluginName ) || o.defaultReveal;

if( init ) {
return false;
if( method === "flip" ) {
$( this )[ pluginName ]( "_createButton" );
}

$( this )
.data( "init." + pluginName, true )
[ pluginName ]( "_init" )
.trigger( "create." + pluginName );
});
},
_init: function() {
var method = $( this ).data( pluginName ) || o.defaultReveal;

if( method === "flip" ) {
$( this )[ pluginName ]( "_createButton" );
}

$( this )
.addClass( pluginName + " " + "method-" + method )
[ pluginName ]( "_createSource" );
},
_createButton: function() {
var btn = document.createElement( "a" ),
txt = document.createTextNode( o.text.open ),
el = $( this );
.addClass( pluginName + " " + "method-" + method )
[ pluginName ]( "_createSource" );
},
_createButton: function() {
var btn = document.createElement( "a" ),
txt = document.createTextNode( o.text.open ),
el = $( this );

btn.setAttribute( "class", o.classes.button );
btn.href = "#";
btn.appendChild( txt );
btn.setAttribute( "class", o.classes.button );
btn.href = "#";
btn.appendChild( txt );

$( btn )
.bind( "click", function( e ) {
var isOpen = el.attr( "class" ).indexOf( o.classes.open ) > -1;
$( btn )
.bind( "click", function( e ) {
var isOpen = el.attr( "class" ).indexOf( o.classes.open ) > -1;

el[ isOpen ? "removeClass" : "addClass" ]( o.classes.open );
btn.innerHTML = ( isOpen ? o.text.open : o.text.close );
el[ isOpen ? "removeClass" : "addClass" ]( o.classes.open );
btn.innerHTML = ( isOpen ? o.text.open : o.text.close );

e.preventDefault();
e.preventDefault();

})
.insertBefore( el );
},
_createSource: function() {
var el = this,
preel = document.createElement( "pre" ),
codeel = document.createElement( "code" ),
wrap = document.createElement( "div" ),
sourcepanel = document.createElement( "div" ),
code = el.innerHTML,
source = document.createTextNode( code );
})
.insertBefore( el );
},
_createSource: function() {
var el = this,
preel = document.createElement( "pre" ),
codeel = document.createElement( "code" ),
wrap = document.createElement( "div" ),
sourcepanel = document.createElement( "div" ),
code = el.innerHTML,
source = document.createTextNode( code );

wrap.setAttribute( "class", "snippet" );
wrap.setAttribute( "class", "snippet" );

$( el ).wrapInner( wrap );
$( el ).wrapInner( wrap );

codeel.appendChild( source );
preel.appendChild( codeel );
codeel.appendChild( source );
preel.appendChild( codeel );

sourcepanel.setAttribute( "class", o.classes.sourcepanel );
sourcepanel.appendChild( preel );
sourcepanel.setAttribute( "class", o.classes.sourcepanel );
sourcepanel.appendChild( preel );

this.appendChild( sourcepanel );
}
};
this.appendChild( sourcepanel );
}
};

// Collection method.
$.fn[ pluginName ] = function( arrg, a, b, c ) {
Expand Down

0 comments on commit fb0f02a

Please sign in to comment.