adding option for fout-b-gone
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
add_action('roots_head', 'roots_google_analytics');
|
add_action('roots_head', 'roots_google_analytics');
|
||||||
|
add_action('roots_head', 'roots_fout_b_gone');
|
||||||
add_action('roots_head', 'roots_1140_head');
|
add_action('roots_head', 'roots_1140_head');
|
||||||
add_action('roots_head', 'roots_adapt_head');
|
add_action('roots_head', 'roots_adapt_head');
|
||||||
add_action('roots_header_before', 'roots_1140_header_before');
|
add_action('roots_header_before', 'roots_1140_header_before');
|
||||||
@@ -11,11 +12,11 @@ add_action('roots_post_inside_before', 'roots_page_breadcrumb');
|
|||||||
|
|
||||||
function roots_google_analytics() {
|
function roots_google_analytics() {
|
||||||
global $roots_options;
|
global $roots_options;
|
||||||
$google_analytics_id = $roots_options['google_analytics_id'];
|
$roots_google_analytics_id = $roots_options['google_analytics_id'];
|
||||||
$get_google_analytics_id = esc_attr($roots_options['google_analytics_id']);
|
$get_roots_google_analytics_id = esc_attr($roots_options['google_analytics_id']);
|
||||||
if ($google_analytics_id !== '') {
|
if ($roots_google_analytics_id !== '') {
|
||||||
echo "\n\t<script>\n";
|
echo "\n\t<script>\n";
|
||||||
echo "\t\tvar _gaq=[['_setAccount','$get_google_analytics_id'],['_trackPageview'],['_trackPageLoadTime']];\n";
|
echo "\t\tvar _gaq=[['_setAccount','$get_roots_google_analytics_id'],['_trackPageview'],['_trackPageLoadTime']];\n";
|
||||||
echo "\t\t(function(d,t){var g=d.createElement(t),s=d.getElementsByTagName(t)[0];g.async=1;\n";
|
echo "\t\t(function(d,t){var g=d.createElement(t),s=d.getElementsByTagName(t)[0];g.async=1;\n";
|
||||||
echo "\t\tg.src=('https:'==location.protocol?'//ssl':'//www')+'.google-analytics.com/ga.js';\n";
|
echo "\t\tg.src=('https:'==location.protocol?'//ssl':'//www')+'.google-analytics.com/ga.js';\n";
|
||||||
echo "\t\ts.parentNode.insertBefore(g,s)}(document,'script'));\n";
|
echo "\t\ts.parentNode.insertBefore(g,s)}(document,'script'));\n";
|
||||||
@@ -23,6 +24,18 @@ function roots_google_analytics() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function roots_fout_b_gone() {
|
||||||
|
global $roots_options;
|
||||||
|
$roots_fout_b_gone = $roots_options['fout_b_gone'];
|
||||||
|
$template_uri = get_template_directory_uri();
|
||||||
|
if ($roots_fout_b_gone === true) {
|
||||||
|
echo "\t<script src=\"$template_uri/js/libs/foutbgone.min.js\"></script>\n";
|
||||||
|
echo "\t<script>\n";
|
||||||
|
echo "\t\tfbg.hideFOUT('asap', 100);\n";
|
||||||
|
echo "\t</script>";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function roots_1140_head() {
|
function roots_1140_head() {
|
||||||
global $roots_options;
|
global $roots_options;
|
||||||
$roots_css_framework = $roots_options['css_framework'];
|
$roots_css_framework = $roots_options['css_framework'];
|
||||||
|
|||||||
@@ -81,7 +81,8 @@ function roots_get_default_theme_options() {
|
|||||||
'main_class' => 'span-14 append-1',
|
'main_class' => 'span-14 append-1',
|
||||||
'sidebar_class' => 'span-8 prepend-1 last',
|
'sidebar_class' => 'span-8 prepend-1 last',
|
||||||
'google_analytics_id' => '',
|
'google_analytics_id' => '',
|
||||||
'clean_menu' => true
|
'clean_menu' => true,
|
||||||
|
'fout_b_gone' => false
|
||||||
);
|
);
|
||||||
|
|
||||||
return apply_filters('roots_default_theme_options', $default_theme_options);
|
return apply_filters('roots_default_theme_options', $default_theme_options);
|
||||||
@@ -161,25 +162,40 @@ function theme_options_render_page() {
|
|||||||
<tr valign="top"><th scope="row"><?php _e('Cleanup Menu Output', 'roots'); ?></th>
|
<tr valign="top"><th scope="row"><?php _e('Cleanup Menu Output', 'roots'); ?></th>
|
||||||
<td>
|
<td>
|
||||||
<fieldset><legend class="screen-reader-text"><span><?php _e('Cleanup Menu Output', 'roots'); ?></span></legend>
|
<fieldset><legend class="screen-reader-text"><span><?php _e('Cleanup Menu Output', 'roots'); ?></span></legend>
|
||||||
<div class="layout">
|
<div>
|
||||||
<label class="description">
|
<label class="description">
|
||||||
<input type="radio" name="roots_theme_options[clean_menu]" value="yes" <?php checked($roots_options['clean_menu'], true); ?> />
|
<input type="radio" name="roots_theme_options[clean_menu]" value="yes" <?php checked($roots_options['clean_menu'], true); ?> />
|
||||||
<span>
|
<span><?php echo _e('Yes', 'roots'); ?></span>
|
||||||
<?php echo _e('Yes', 'roots'); ?>
|
</label>
|
||||||
</span>
|
</div>
|
||||||
</label>
|
<div>
|
||||||
</div>
|
<label class="description">
|
||||||
<div class="layout">
|
<input type="radio" name="roots_theme_options[clean_menu]" value="no" <?php checked($roots_options['clean_menu'], false); ?> />
|
||||||
<label class="description">
|
<span><?php echo _e('No', 'roots'); ?></span>
|
||||||
<input type="radio" name="roots_theme_options[clean_menu]" value="no" <?php checked($roots_options['clean_menu'], false); ?> />
|
</label>
|
||||||
<span>
|
</div>
|
||||||
<?php echo _e('No', 'roots'); ?>
|
|
||||||
</span>
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
|
<tr valign="top"><th scope="row"><?php _e('Enable FOUT-B-Gone', 'roots'); ?></th>
|
||||||
|
<td>
|
||||||
|
<fieldset><legend class="screen-reader-text"><span><?php _e('Enable FOUT-B-Gone', 'roots'); ?></span></legend>
|
||||||
|
<div>
|
||||||
|
<label class="description">
|
||||||
|
<input type="radio" name="roots_theme_options[fout_b_gone]" value="yes" <?php checked($roots_options['fout_b_gone'], true); ?> />
|
||||||
|
<span><?php echo _e('Yes', 'roots'); ?></span>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label class="description">
|
||||||
|
<input type="radio" name="roots_theme_options[fout_b_gone]" value="no" <?php checked($roots_options['fout_b_gone'], false); ?> />
|
||||||
|
<span><?php echo _e('No', 'roots'); ?></span>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</fieldset>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
@@ -216,7 +232,10 @@ function roots_theme_options_validate($input) {
|
|||||||
$output['google_analytics_id'] = $input['google_analytics_id'];
|
$output['google_analytics_id'] = $input['google_analytics_id'];
|
||||||
|
|
||||||
if (isset($input['clean_menu']))
|
if (isset($input['clean_menu']))
|
||||||
$output['clean_menu'] = ($input['clean_menu'] === 'yes') ? true : false;
|
$output['clean_menu'] = ($input['clean_menu'] === 'yes') ? true : false;
|
||||||
|
|
||||||
|
if (isset($input['fout_b_gone']))
|
||||||
|
$output['fout_b_gone'] = ($input['fout_b_gone'] === 'yes') ? true : false;
|
||||||
|
|
||||||
return apply_filters('roots_theme_options_validate', $output, $input, $defaults);
|
return apply_filters('roots_theme_options_validate', $output, $input, $defaults);
|
||||||
}
|
}
|
||||||
|
|||||||
70
js/libs/foutbgone.min.js
vendored
Normal file
70
js/libs/foutbgone.min.js
vendored
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
/**
|
||||||
|
* WebINK's Fout-B-Gone is a single object that offers various methods for using and
|
||||||
|
* managing custom Web Fonts added to webpages through the @font-face CSS rule.
|
||||||
|
*
|
||||||
|
* Note: This is a work in progress and other useful font-related methods may be added in the future
|
||||||
|
*
|
||||||
|
* Current methods:
|
||||||
|
*
|
||||||
|
* fbg.hideFOUT -- automatically gets rid of undesirable flash-of-unstyled-text
|
||||||
|
* that occurs with some browsers, such as FF 3.6 and IE9
|
||||||
|
*
|
||||||
|
* fbg.isFontFaceSupported -- returns true or false indicating if browser supports @font-face
|
||||||
|
* This is the code written by Diego Perini as reported by Paul Irish on
|
||||||
|
* 2010.11.02 at http://paulirish.com/2009/font-face-feature-detection
|
||||||
|
* We've included this check here in the form of a method for convenience;
|
||||||
|
* it is not necessary for other fbg methods.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @author Jay Vilhena <jvilhena@extensis.com>
|
||||||
|
* @version 0.1
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
THE SOFTWARE.
|
||||||
|
|
||||||
|
*/
|
||||||
|
/***************************************************************************************/
|
||||||
|
var fbg=new function()
|
||||||
|
{var self=this;var test_frequency=20;var giveup=3000;var latency=100;this.rfu=null;var init=null;var onWinLoad=null;this.hideFOUT=null;this.isFontFaceSupported=null;this.onFontFaceFailed=null;init=function()
|
||||||
|
{};onWinLoad=function(callback)
|
||||||
|
{if(window.addEventListener)addEventListener('load',callback,false);else attachEvent('onload',callback);};this.hideFOUT=function(when,delay)
|
||||||
|
{if(navigator.appName!='Microsoft Internet Explorer'&&!/Firefox\/3/.test(navigator.userAgent))
|
||||||
|
return;delay=delay||latency;var fontnams=[];var fontruls=[];var selectrs=[];var iscompliant=true;for(var i=0;i<document.styleSheets.length;i++)
|
||||||
|
{var stylsheet=document.styleSheets[i];if(!stylsheet.cssRules)
|
||||||
|
{iscompliant=false;var rls=stylsheet.cssText;rls.replace(/@font-face\s*\{([^\}]+)\}/ig,function(r,t){var fontnam=r.replace(/([\s\S]*)(font-family:\s*['"]?)([-_0-9a-zA-Z]+)([\s\S]*)/,"$3");fontnams.push(fontnam);return r;});}
|
||||||
|
var ffrules=stylsheet.cssRules||stylsheet.rules;for(var j=0;j<ffrules.length;j++)
|
||||||
|
{var rul=ffrules[j];if(iscompliant&&rul instanceof CSSFontFaceRule)
|
||||||
|
{var fontnam=rul.cssText.replace(/([\s\S]*)(font-family:\s*['"]?)([-_0-9a-zA-Z]+)([\s\S]*)/,"$3");fontnams.push(fontnam);}
|
||||||
|
else fontruls.push(rul);}}
|
||||||
|
for(var i=0;i<fontnams.length;i++)
|
||||||
|
{for(var j=0;j<fontruls.length;j++)
|
||||||
|
{var csstxt=iscompliant?fontruls[j].cssText:fontruls[j].style.cssText;if(csstxt.indexOf(fontnams[i])!=-1)
|
||||||
|
{selectrs.push(fontruls[j].selectorText);}}}
|
||||||
|
var body=document.body||document.documentElement;var spn=document.createElement('span');spn.setAttribute('style','font:99px _,serif;position:absolute;visibility:hidden');spn.innerHTML='Hello World';spn.id='fonttest';body.appendChild(spn);var stl1=document.createElement('style');document.getElementsByTagName("head")[0].appendChild(stl1);var allhidden='';for(var i=0;i<selectrs.length;i++)
|
||||||
|
allhidden+=(selectrs[i]+(i<(selectrs.length-1)?', ':' '));allhidden+='{visibility:hidden}';if(stl1.styleSheet)stl1.styleSheet.cssText=allhidden;else stl1.textContent=allhidden;spn.style.font='99px "'+fontnams[fontnams.length-1]+'",_,serif';var wid=spn.offsetWidth;var temp1='';var freq=test_frequency;var showHidden=function()
|
||||||
|
{var fnttest=setInterval(function()
|
||||||
|
{if(!wid&&document.body)
|
||||||
|
{body.removeChild(spn);document.body.appendChild(spn);wid=spn.offsetWidth;}
|
||||||
|
var nu_wid=spn.offsetWidth;temp1+=(nu_wid+' ');giveup-=freq;if(wid!=nu_wid||giveup<=0)
|
||||||
|
{clearInterval(fnttest);setTimeout(function(){stl1.parentNode.removeChild(stl1);},delay);if(giveup<=0&&self.onFontFaceFailed)self.onFontFaceFailed();spn.parentNode.removeChild(spn);}},freq);}
|
||||||
|
if(when=='asap')showHidden();else if(when=='onload')onWinLoad(showHidden);else showHidden();if(window.TESTCAPTURE)
|
||||||
|
{onWinLoad(function()
|
||||||
|
{document.getElementById('hf_monitor_div').innerHTML=temp1;setTimeout(function(){document.getElementById('hf_monitor_div').innerHTML+='<br>Final: '+spn.offsetWidth;},1000);});}};this.isFontFaceSupported=function()
|
||||||
|
{var
|
||||||
|
sheet,doc=document,head=doc.head||doc.getElementsByTagName('head')[0]||docElement,style=doc.createElement("style"),impl=doc.implementation||{hasFeature:function(){return false;}};style.type='text/css';head.insertBefore(style,head.firstChild);sheet=style.sheet||style.styleSheet;var supportAtRule=impl.hasFeature('CSS2','')?function(rule){if(!(sheet&&rule))return false;var result=false;try{sheet.insertRule(rule,0);result=!(/unknown/i).test(sheet.cssRules[0].cssText);sheet.deleteRule(sheet.cssRules.length-1);}catch(e){}
|
||||||
|
return result;}:function(rule){if(!(sheet&&rule))return false;sheet.cssText=rule;return sheet.cssText.length!==0&&!(/unknown/i).test(sheet.cssText)&&sheet.cssText.replace(/\r+|\n+/g,'').indexOf(rule.split(' ')[0])===0;};return supportAtRule('@font-face { font-family: "font"; src: "font.ttf"; }');};init();}();
|
||||||
Reference in New Issue
Block a user