Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rewrite demo page to be function and sans jQuery.
- Loading branch information
Showing
3 changed files
with
118 additions
and
127 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,18 @@ | ||
/** | ||
* Gridicons Demo page JS | ||
* Genericons Neue Demo page JS | ||
*/ | ||
(function( $ ){ | ||
// Kick things off | ||
$( document ).ready( function() { | ||
initEvents(); | ||
}); | ||
function initEvents() { | ||
var $rows = $('#icons').find('svg'); | ||
// When you click on an icon | ||
$rows.on( 'click', function() { | ||
var attr = $( this ).find( 'use' ).attr( 'xlink:href' ), | ||
cssClass = attr.split( '#' )[1]; | ||
|
||
suggestCode( attr, cssClass ); | ||
|
||
}); | ||
} | ||
function suggestCode( attr, cssClass ) { | ||
|
||
var fileLocation = '//s1.wp.com/i/gridicons.svg', // @todo: needs to be updated with final location | ||
suggestion = '<svg class="gridicon '+ cssClass +'" width="24px" height="24px"><use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="' + fileLocation + attr + '"></use></svg>'; | ||
|
||
window.prompt( "Copy this, paste in your HTML.\n\nRemember to update the gridicons.svg file as well!", suggestion ); | ||
window.onload = function () { | ||
|
||
var rows = document.getElementsByTagName( 'svg' ); | ||
|
||
for ( i=0; i<rows.length; i++ ) { | ||
rows[i].onclick = function () { | ||
var cssClass = this.getAttribute( 'class' ); | ||
var iconID = '#' + cssClass.split(' genericons-neue-')[1]; | ||
var fileLocation = 'genericons-neue.svg'; | ||
var suggestion = '<svg class="'+ cssClass +'" width="16px" height="16px"><use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="' + fileLocation + iconID + '"></use></svg>'; | ||
window.prompt( 'Copy this, paste in your HTML.', suggestion ); | ||
} | ||
} | ||
})( jQuery ); | ||
} |
Oops, something went wrong.