Skip to content

Commit

Permalink
Better bootstrap 'button' integration [#1101]
Browse files Browse the repository at this point in the history
  • Loading branch information
dleffler committed Dec 4, 2013
1 parent 5837f4a commit 99e48ac
Show file tree
Hide file tree
Showing 70 changed files with 546 additions and 309 deletions.
10 changes: 7 additions & 3 deletions framework/core/forms/controls/bootstrap/buttongroupcontrol.php
Expand Up @@ -60,9 +60,13 @@ function controlToHTML($name,$label=null) {
if (empty($this->id)) $this->id = $name;
$html = "";
if ($this->submit != "") {
$btn_size = 'btn-'.BTN_SIZE;
$icon_size = 'icon-'.BTN_SIZE;

if (BTN_SIZE == 'large') {
$btn_size = 'btn-small';
$icon_size = 'icon-large';
} else {
$btn_size = 'btn-mini';
$icon_size = '';
}
if (stripos($this->submit, 'save') !== false) {
$icon = 'icon-save';
} elseif (stripos($this->submit, 'log') !== false) {
Expand Down
6 changes: 3 additions & 3 deletions framework/core/forms/form.php
Expand Up @@ -216,19 +216,19 @@ function toHTML($form_id=null, $module=null) {
$html = "<!-- Form Object '" . $this->name . "' -->\r\n";
// $html .= '<script type="text/javascript" src="'.PATH_RELATIVE.'framework/core/forms/js/required.js"></script>'."\r\n";
$html .= "<script type=\"text/javascript\" src=\"" .PATH_RELATIVE."framework/core/forms/js/inputfilters.js.php\"></script>\r\n";
if(expSession::get('framework')!='bootstrap'){
if (expSession::get('framework') != 'bootstrap') {
expCSS::pushToHead(array(
// "unique" => 'forms',
"corecss"=>"forms"
));
$btn_class = 'awesome ".BTN_SIZE." ".BTN_COLOR."';
$btn_class = "awesome " . BTN_SIZE . " " . BTN_COLOR;
} else {
expCSS::pushToHead(array(
// "unique" => 'z-forms-bootstrap',
"corecss"=>"forms-bootstrap"
));
$btn_class = 'btn btn-default';
};
}
expJavascript::pushToFoot(array(
"unique" => 'html5forms1',
"src"=> PATH_RELATIVE . 'external/html5forms/modernizr-262.js',
Expand Down
118 changes: 117 additions & 1 deletion framework/core/subsystems/expCore.php
Expand Up @@ -423,7 +423,7 @@ public static function resolveFilePaths($type, $name, $subtype, $subname) {
* @return array
* @node Subsystems:expCore
*/
public static function buildNameList($type, $name, $subtype, $subname) { //FIXME only used by 1) calendarmodule edit action (email forms) & 2) expTemplate::listModuleViews for OS modules
public static function buildNameList($type, $name, $subtype, $subname) { //FIXME only used by 1) event module edit action (email forms) & 2) expTemplate::listModuleViews for OS modules
$nameList = array();
$fileList = self::resolveFilePaths($type, $name, $subtype, $subname);
if ($fileList != false) {
Expand Down Expand Up @@ -548,5 +548,121 @@ public static function cast($source, $destinationtype) {
}
return $destination;
}

/**
* Return the 'color code' for the other framework
* default is to convert a standard button color to the bootstrap button color
*
* @param $color
* @param string $returntype
*
* @return mixed|string
*/
public static function buttonColor($color, $returntype='bootstrap') {
$colors = array(
'red' => 'btn-danger',
'yellow' => 'btn-warning',
'grey' => 'btn-default',
'green' => 'btn-success',
'blue' => 'btn-primary'
);
if ($returntype == 'bootstrap') {
if (!empty($colors[$color])) {
$found = $colors[$color];
} else {
$found = 'btn-default';
}
return $found;
} else {
return array_search($color, $colors);
}
}

/**
* Return the bootstrap icon type associated with standard icon name/type
*
* @param $class
* @param string $returntype
*
* @return stdClass|string
*/
public static function buttonIcon($class, $returntype='bootstrap') {
if ($returntype == 'bootstrap') {
$btn_type = '';
switch ($class) {
case 'delete' :
case 'deletetitle' :
$class = "remove-sign";
$btn_type = "btn-danger"; // red
break;
case 'add' :
case 'addtitle' :
case 'switchtheme add' :
$class = "plus-sign add";
$btn_type = "btn-success"; // green
break;
case 'copy' :
$class = "copy";
break;
case 'downloadfile' :
case 'export' :
$class = "download-alt";
break;
case 'uploadfile' :
case 'import' :
$class = "upload-alt";
break;
case 'manage' :
$class = "briefcase";
break;
case 'merge' :
case 'arrow_merge' :
$class = "signin";
break;
case 'reranklink' :
case 'alphasort' :
$class = "sort";
break;
case 'configure' :
$class = "wrench";
break;
case 'view' :
$class = "search";
break;
case 'page_next' :
$class ='double-angle-right';
break;
case 'page_prev' :
$class = 'double-angle-left';
break;
case 'change_password' :
$class = 'key';
break;
case 'clean' :
$class = 'check';
break;
case 'groupperms' :
$class = 'group';
break;
case 'monthviewlink' :
case 'weekviewlink' :
$class = 'calendar';
break;
case 'listviewlink' :
$class = 'list';
break;
case 'adminviewlink' :
$class = 'cogs';
break;
}
$found = new stdClass();
$found->type = $btn_type;
$found->class = $class;
return $found;
} else {
return $class;
}
}

}
?>
Expand Up @@ -82,5 +82,7 @@
{/foreach}
</tbody>
</table>
<a class="awesome {$smarty.const.BTN_SIZE} {$smarty.const.BTN_COLOR}" href="{backlink}">{"Done"|gettext}</a>
{*<a class="{button_style}" href="{backlink}">{"Done"|gettext}</a>*}
{$backlink = makeLink(expHistory::getBack(1))}
{icon button=true link=$backlink text="Done"|gettext}
</div>
Expand Up @@ -136,7 +136,8 @@
</div>
{control type="dropdown" name="sc[LANGUAGE]" label="Display Language"|gettext items=$langs default=$smarty.const.LANGUAGE}
{*{control type="dropdown" name="sc[DISPLAY_THEME_REAL]" label="Theme <a href=\"manage_themes\">(More Theme Options)</a>"|gettext items=$themes default=$smarty.const.DISPLAY_THEME_REAL}*}
<h3><a href="manage_themes">{'Display Theme Options'|gettext}</a></h3>
{*<h3><a href="manage_themes">{'Display Theme Options'|gettext}</a></h3>*}
{icon button=true link="manage_themes" text='Display Theme Options'|gettext}
{control type="checkbox" postfalse=1 name="sc[INVERT_HIDE_TITLE]" label="Reverse the Logic of Hide Module Title setting?"|gettext checked=$smarty.const.INVERT_HIDE_TITLE value=1 description='Changes default of always show title to always hide title, unless module setting is checked.'|gettext}
{control type="checkbox" postfalse=1 name="sc[FORCE_MOBILE]" label="Force Display of the Mobile Theme Variation (if available)?"|gettext checked=$smarty.const.FORCE_MOBILE value=1}
{group label="Display Formats"|gettext}
Expand Down Expand Up @@ -262,7 +263,7 @@
</div>
{control type="text" name="sc[SITE_404_TITLE]" label='Page Title For \'Not Found\' (404) Error'|gettext value=$smarty.const.SITE_404_TITLE}
{control type="html" name="sc[SITE_404_HTML]" label='\'Not Found\' (404) Error Message'|gettext value=$smarty.const.SITE_404_HTML}
{control type="html" name="sc[SITE_403_REAL_HTML]" label='\'Access Denied\' (403/401) Error Message'|gettext value=$smarty.const.SITE_403_REAL_HTML}
{control type="html" name="sc[SITE_403_REAL_HTML]" label='\'Access Denied\' (403) Error Message'|gettext value=$smarty.const.SITE_403_REAL_HTML}
{control type="html" name="sc[SESSION_TIMEOUT_HTML]" label='\'Session Expired\' Error Message'|gettext value=$smarty.const.SESSION_TIMEOUT_HTML}
</div>
<div id="tab13">
Expand Down Expand Up @@ -446,7 +447,8 @@
</div>
{control type="dropdown" name="profiles" label="Load configuration profile"|gettext items=$profiles default=$smarty.const.CURRENTCONFIGNAME onchange="changeProfile(this.value)"}
{control type="text" name="profile_name" label="New Profile Name"|gettext value=$smarty.const.CURRENTCONFIGNAME}
<a class="awesome {$smarty.const.BTN_SIZE} {$smarty.const.BTN_COLOR}" href="#" onclick="saveProfile()"><strong>{'Save New Profile'|gettext}</strong></a>
{*<a class="{button_style}" href="#" onclick="saveProfile()"><strong>{'Save New Profile'|gettext}</strong></a>*}
{icon button=true action=scriptaction onclick="saveProfile()" text='Save New Profile'|gettext}
</div>
{/if}
</div>
Expand Down Expand Up @@ -490,14 +492,14 @@
{script unique="wysiwyg-type" yui3mods="node,node-event-simulate"}
{literal}
YUI(EXPONENT.YUI3_CONFIG).use('node','node-event-simulate', function(Y) {
var radioSwitchers = Y.all('#alt-controlw input[type="radio"]');
radioSwitchers.on('click',function(e){
Y.all(".alt-item").setStyle('display','none');
var radioSwitchersw = Y.all('#alt-controlw input[type="radio"]');
radioSwitchersw.on('click',function(e){
Y.all("#alt-controlw .alt-item").setStyle('display','none');
var curdiv = Y.one("#" + e.target.get('value') + "-div");
curdiv.setStyle('display','block');
});

radioSwitchers.each(function(node,k){
radioSwitchersw.each(function(node,k){
if(node.get('checked')==true){
node.simulate('click');
}
Expand All @@ -511,7 +513,7 @@ YUI(EXPONENT.YUI3_CONFIG).use('node','node-event-simulate', function(Y) {
YUI(EXPONENT.YUI3_CONFIG).use('node','node-event-simulate', function(Y) {
var radioSwitchers = Y.all('#alt-control input[type="radio"]');
radioSwitchers.on('click',function(e){
Y.all(".alt-item").setStyle('display','none');
Y.all("#alt-control .alt-item").setStyle('display','none');
var curdiv = Y.one("#" + e.target.get('value') + "-div");
curdiv.setStyle('display','block');
});
Expand Down
Expand Up @@ -67,7 +67,8 @@
{* <hr size="1" />*}
{if $failed == 0}
{if $warn == 1}{'<strong>Note:</strong> Continuing with the installation will overwrite existing files. It is <strong>highly recommended</strong> that you ensure that you want to do this.'|gettext}<br /><br />{/if}
<a class="awesome {$smarty.const.BTN_SIZE} {$smarty.const.BTN_COLOR}" href="{link action=install_extension_finish patch=$patch}">{'Continue with Installation'|gettext}</a>
{*<a class="{button_style}" href="{link action=install_extension_finish patch=$patch}">{'Continue with Installation'|gettext}</a>*}
{icon button=true action=install_extension_finish patch=$patch text='Continue with Installation'|gettext}
{else}
{'Permissions on the webserver are preventing the installation of this extension. Please make the necessary directories writable, and then reload this page to continue.'|gettext}
{/if}
Expand Down
Expand Up @@ -82,6 +82,7 @@
{/foreach}
</tbody>
</table>
<a class="awesome {$smarty.const.BTN_SIZE} {$smarty.const.BTN_COLOR}" href="{$redirect}">{'Back'|gettext}</a>
{*<a class="{button_style}" href="{$redirect}">{'Back'|gettext}</a>*}
{icon button=true link$redirect text='Back'|gettext}
{/if}
</div>
5 changes: 5 additions & 0 deletions framework/modules/ecommerce/assets/css/ecom.css
Expand Up @@ -10,6 +10,11 @@
/* border-width:0 1px 1px 1px;*/
}

.exp-ecom-table .radio table {
border:none;
/* border-width:0 1px 1px 1px;*/
}

.exp-ecom-table table.collapse {
width:10%;
}
Expand Down
5 changes: 2 additions & 3 deletions framework/modules/ecommerce/assets/css/report-builder.css
Expand Up @@ -2,10 +2,9 @@
margin-top:10px;
}


.build-report .control {
padding:0;
margin:0;
/*padding:0;*/
/*margin:0;*/
float:left;
}

Expand Down
Expand Up @@ -25,8 +25,10 @@
{control type="text" name="dollar_amount" label="Dollar Amount:"|gettext value=$product->base_price size=7 filter=money}
{*control type="buttongroup" name="add2cart" submit="Pay now"*}
{/form}
<a id="paynow" class="add-to-cart-btn awesome {$smarty.const.BTN_SIZE} {$smarty.const.BTN_COLOR} rc-link" href="">{'Donate now'|gettext}<span></span></a> or
<a id="continue" class="add-to-cart-btn awesome {$smarty.const.BTN_SIZE} {$smarty.const.BTN_COLOR} rc-link" href="{link controller=cart action=addItem}">{'Add to cart and continue shopping'|gettext}<span></span></a>
{*<a id="paynow" class="add-to-cart-btn {button_style} rc-link" href="">{'Donate now'|gettext}<span></span></a> or*}
{icon id="paynow" class="add-to-cart-btn rc-link" button=true action=scriptaction text='Donate now'|gettext}<span></span></a> {'OR'|gettext}
{*<a id="continue" class="add-to-cart-btn {button_style} rc-link" href="{link controller=cart action=addItem}">{'Add to cart and continue shopping'|gettext}<span></span></a>*}
{icon id="continue" class="add-to-cart-btn rc-link" button=true controller=cart action=addItem text='Add to cart and continue shopping'|gettext}<span></span>
</div>

{*FIXME convert to yui3*}
Expand Down
Expand Up @@ -28,9 +28,11 @@
{control type=tel id="registrations_phones" name="registrant_phones[]" label="Registrant Phone:"|gettext}
<hr>
</div>
<a class="exp-ecom-link plus addtocart add-to-cart-btn awesome {$smarty.const.BTN_SIZE} {$smarty.const.BTN_COLOR} rc-link" id="newregistrant" href="#"><em>{'Add another registrant'|gettext}</em> <span></span></a>
{*<a class="exp-ecom-link plus addtocart add-to-cart-btn {button_style} rc-link" id="newregistrant" href="#"><em>{'Add another registrant'|gettext}</em> <span></span></a>*}
{icon class="exp-ecom-link plus addtocart add-to-cart-btn rc-link" id="newregistrant" button=true action=scriptaction text='Add another registrant'|gettext}<span></span>
&#160;&#160; {'OR'|gettext} &#160;
<a class="exp-ecom-link addtocart add-to-cart-btn awesome {$smarty.const.BTN_SIZE} {$smarty.const.BTN_COLOR} rc-link" onclick="EXPONENT.validateReg()" href="#"><em>{'Add Registration to Cart'|gettext}</em><span></span></a>
{*<a class="exp-ecom-link addtocart add-to-cart-btn {button_style} rc-link" onclick="EXPONENT.validateReg()" href="#"><em>{'Add Registration to Cart'|gettext}</em><span></span></a>*}
{icon class="exp-ecom-link addtocart add-to-cart-btn rc-link" button=true onclick="EXPONENT.validateReg()" action=noaction text='Add Registration to Cart'|gettext}<span></span>
{/form}
</div>

Expand Down
Expand Up @@ -15,24 +15,25 @@

<div class="product">
{if $listing->availability_type != 3 && $listing->active_type == 0}
<a href="{link controller=store action=show title=$listing->sef_url}" class="exp-ecom-link awesome {$smarty.const.BTN_SIZE} {$smarty.const.BTN_COLOR}">{"View Item"|gettext}</a>
{*if $listing->hasChildren()}
<a href="{link controller=store action=show title=$listing->sef_url}" class="exp-ecom-link awesome {$smarty.const.BTN_SIZE} {$smarty.const.BTN_COLOR}">{"View Item"|gettext}</a>
{*<a href="{link controller=store action=show title=$listing->sef_url}" class="exp-ecom-link {button_style}">{"View Item"|gettext}</a>*}
{icon controller=store action=show title=$listing->sef_url class="exp-ecom-link" button=true text="View Item"|gettext}
{*if $listing->hasChildren()}
<a href="{link controller=store action=show title=$listing->sef_url}" class="exp-ecom-link {button_style}">{"View Item"|gettext}</a>
{else}
{form id="addtocart`$listing->id`" controller=cart action=addItem}
{control type="hidden" name="product_id" value="`$listing->id`"}
{control type="hidden" name="product_type" value="`$listing->product_type`"}
<button type="submit" class="awesome {$smarty.const.BTN_SIZE} {$smarty.const.BTN_COLOR}">{"Add to Cart"|gettext}</button>
<button type="submit" class="{button_style}">{"Add to Cart"|gettext}</button>
{if $listing->parent_id == 0}
{control name="qty" type="text" value="`$listing->minimum_order_quantity`" size=3 maxlength=5 class="lstng-qty"}
{/if}
{/form}
{/if*}
{else}
{if $listing->active_type == 1}
<a href="{link controller=store action=show title=$listing->sef_url}" class="exp-ecom-link awesome {$smarty.const.BTN_SIZE} grey">{"View Item"|gettext}</a>
<a href="{link controller=store action=show title=$listing->sef_url}" class="exp-ecom-link {button_style color=grey}">{"View Item"|gettext}</a>
{elseif $listing->active_type == 2 && $user->isAdmin()}
<a href="{link controller=store action=show title=$listing->sef_url}" class="exp-ecom-link awesome {$smarty.const.BTN_SIZE} red">{"View Item"|gettext}</a>
<a href="{link controller=store action=show title=$listing->sef_url}" class="exp-ecom-link {button_style color=red}">{"View Item"|gettext}</a>
{/if}
{/if}
<div class="prod-price">
Expand Down
Expand Up @@ -21,7 +21,8 @@
{form name="ccinfoform" id="ccinfoform" controller=cart action=preprocess}
{control type="hidden" name="billingcalculator_id" value=$calcid}
{$billing->form.$calcid}
<button id="continue-checkout" type="submit" class="awesome {$smarty.const.BTN_SIZE} {$smarty.const.BTN_COLOR}">{'Continue Checkout'|gettext}</button>
{*<button id="continue-checkout" type="submit" class="{button_style}">{'Continue Checkout'|gettext}</button>*}
{control type="buttongroup" id="continue-checkout" class="add-to-cart-btn" submit="Continue Checkout"|gettext}
{/form}
</div>

Expand Down
3 changes: 2 additions & 1 deletion framework/modules/ecommerce/views/billing/cash.tpl
Expand Up @@ -21,6 +21,7 @@
{form name="ccinfoform`$key`" controller=cart action=preprocess}
{control type="hidden" name="billingcalculator_id" value=$calcid}
{$billing->form.$calcid}
<button id="continue-checkout" type="submit" class="add-to-cart-btn awesome {$smarty.const.BTN_SIZE} {$smarty.const.BTN_COLOR}">{"Continue Checkout"|gettext}</button>
{*<button id="continue-checkout" type="submit" class="add-to-cart-btn {button_style}">{"Continue Checkout"|gettext}</button>*}
{control type="buttongroup" id="continue-checkout" class="add-to-cart-btn" submit="Continue Checkout"|gettext}
{/form}
</div>

0 comments on commit 99e48ac

Please sign in to comment.