diff --git a/core/lib/Thelia/Config/Resources/routing/front.xml b/core/lib/Thelia/Config/Resources/routing/front.xml index aeff55d7c..d06585f73 100755 --- a/core/lib/Thelia/Config/Resources/routing/front.xml +++ b/core/lib/Thelia/Config/Resources/routing/front.xml @@ -15,17 +15,29 @@ connexion + + Thelia\Controller\Front\DefaultController::noAction + register + + Thelia\Controller\Front\CustomerController::updateAction Thelia\Controller\Front\CustomerController::loginAction + login + + + + Thelia\Controller\Front\DefaultController::noAction + login Thelia\Controller\Front\CustomerController::logoutAction + diff --git a/core/lib/Thelia/Controller/BaseController.php b/core/lib/Thelia/Controller/BaseController.php index 666e8ca32..5e992b258 100755 --- a/core/lib/Thelia/Controller/BaseController.php +++ b/core/lib/Thelia/Controller/BaseController.php @@ -179,7 +179,14 @@ class BaseController extends ContainerAware return $form; } else { - throw new FormValidationException(sprintf("Missing or invalid data: %s", $this->getErrorMessages($form))); + $errorMessage = null; + if ($form->get("error_message")->getData() != null) { + $errorMessage = $form->get("error_message")->getData(); + } else { + $errorMessage = sprintf("Missing or invalid data: %s", $this->getErrorMessages($form)); + } + + throw new FormValidationException($errorMessage); } } else { diff --git a/core/lib/Thelia/Controller/Front/BaseFrontController.php b/core/lib/Thelia/Controller/Front/BaseFrontController.php index e92387a83..ed6774c8b 100755 --- a/core/lib/Thelia/Controller/Front/BaseFrontController.php +++ b/core/lib/Thelia/Controller/Front/BaseFrontController.php @@ -22,6 +22,7 @@ /*************************************************************************************/ namespace Thelia\Controller\Front; +use Symfony\Component\Routing\Router; use Thelia\Controller\BaseController; use Thelia\Tools\URL; @@ -34,8 +35,8 @@ class BaseFrontController extends BaseController * * @see \Thelia\Controller\BaseController::getRouteFromRouter() */ - protected function getRoute($routeId) { - return $this->getRouteFromRouter('router.front', $routeId); + protected function getRoute($routeId, $parameters = array(), $referenceType = Router::ABSOLUTE_PATH) { + return $this->getRouteFromRouter('router.front', $routeId, $parameters, $referenceType); } /** @@ -44,7 +45,7 @@ class BaseFrontController extends BaseController * @param unknown $routeId the route ID, as found in Config/Resources/routing/admin.xml * @param unknown $urlParameters the URL parametrs, as a var/value pair array */ - public function redirectToRoute($routeId, $urlParameters = array()) { - $this->redirect(URL::getInstance()->absoluteUrl($this->getRoute($routeId), $urlParameters)); + public function redirectToRoute($routeId, $urlParameters = array(), $referenceType = Router::ABSOLUTE_PATH) { + $this->redirect(URL::getInstance()->absoluteUrl($this->getRoute($routeId, array(), $referenceType), $urlParameters)); } } diff --git a/core/lib/Thelia/Controller/Front/CustomerController.php b/core/lib/Thelia/Controller/Front/CustomerController.php index d753510a6..58d578955 100755 --- a/core/lib/Thelia/Controller/Front/CustomerController.php +++ b/core/lib/Thelia/Controller/Front/CustomerController.php @@ -39,6 +39,7 @@ use Thelia\Core\Factory\ActionEventFactory; use Thelia\Tools\URL; use Thelia\Log\Tlog; use Thelia\Core\Security\Exception\WrongPasswordException; +use Symfony\Component\Routing\Router; /** * Class CustomerController @@ -167,16 +168,25 @@ class CustomerController extends BaseFrontController } catch (FormValidationException $e) { + + if ($request->request->has("account")) { + $account = $request->request->get("account"); + $form = $customerLoginForm->getForm(); + if($account == 0 && $form->get("email")->getData() !== null) { + $this->redirectToRoute("customer.create.view", array("email" => $form->get("email")->getData())); + } + } + $message = sprintf("Please check your input: %s", $e->getMessage()); } catch(UsernameNotFoundException $e) { - $message = "This customer email was not found."; + $message = "Wrong email or password. Please try again"; } catch (WrongPasswordException $e) { - $message = "Wrong password. Please try again."; + $message = "Wrong email or password. Please try again"; } catch(AuthenticationException $e) { - $message = "Sorry, we failed to authentify you. Please try again."; + $message = "Wrong email or password. Please try again"; } catch (\Exception $e) { $message = sprintf("Sorry, an error occured: %s", $e->getMessage()); diff --git a/core/lib/Thelia/Core/HttpFoundation/Session/Session.php b/core/lib/Thelia/Core/HttpFoundation/Session/Session.php index 8c6a241ec..fc2726647 100755 --- a/core/lib/Thelia/Core/HttpFoundation/Session/Session.php +++ b/core/lib/Thelia/Core/HttpFoundation/Session/Session.php @@ -28,6 +28,7 @@ use Thelia\Core\Security\User\UserInterface; use Thelia\Exception\InvalidCartException; use Thelia\Model\CartQuery; use Thelia\Model\Cart; +use Thelia\Model\Currency; use Thelia\Tools\URL; use Thelia\Model\Lang; @@ -44,9 +45,9 @@ class Session extends BaseSession /** * @return \Thelia\Model\Lang|null */ - public function getLang() + public function getLang($forceDefault = true) { - return $this->get("thelia.current.lang", Lang::getDefaultLanguage()); + return $this->get("thelia.current.lang", $forceDefault ? Lang::getDefaultLanguage():null); } public function setLang(Lang $lang) @@ -68,6 +69,16 @@ class Session extends BaseSession return $this; } + public function setCurrency(Currency $currency) + { + $this->set("thelia.current.currency", $currency); + } + + public function getCurrency($forceDefault = true) + { + return $this->get("thelia.current.currency", $forceDefault ? Currency::getDefaultCurrency():null); + } + // -- Customer user -------------------------------------------------------- public function setCustomerUser(UserInterface $user) diff --git a/core/lib/Thelia/Core/Template/Smarty/Plugins/DataAccessFunctions.php b/core/lib/Thelia/Core/Template/Smarty/Plugins/DataAccessFunctions.php index 1fdb6e4bf..fded12c0e 100755 --- a/core/lib/Thelia/Core/Template/Smarty/Plugins/DataAccessFunctions.php +++ b/core/lib/Thelia/Core/Template/Smarty/Plugins/DataAccessFunctions.php @@ -31,6 +31,7 @@ use Thelia\Core\Template\ParserContext; use Thelia\Core\Template\Smarty\SmartyPluginDescriptor; use Thelia\Model\CategoryQuery; use Thelia\Model\ContentQuery; +use Thelia\Model\CurrencyQuery; use Thelia\Model\FolderQuery; use Thelia\Model\Product; use Thelia\Model\ProductQuery; @@ -132,6 +133,35 @@ class DataAccessFunctions extends AbstractSmartyPlugin } } + /** + * currency global data + * + * @param $params + * @param $smarty + */ + public function currencyDataAccess($params, $smarty) + { + $currency = $this->request->getSession()->getCurrency(); + + if ($currency) { + $currencyQuery = CurrencyQuery::create() + ->filterById($currency->getId()); + + return $this->dataAccessWithI18n("Currency", $params, $currencyQuery, array("NAME")); + } + } + + /** + * Lang global data + * + * @param $params + * @param $smarty + */ + public function langDataAccess($params, $smarty) + { + return $this->dataAccess("Lang", $params, $this->request->getSession()->getLang()); + } + /** * @param $objectLabel * @param $params @@ -231,6 +261,8 @@ class DataAccessFunctions extends AbstractSmartyPlugin new SmartyPluginDescriptor('function', 'category', $this, 'categoryDataAccess'), new SmartyPluginDescriptor('function', 'content', $this, 'contentDataAccess'), new SmartyPluginDescriptor('function', 'folder', $this, 'folderDataAccess'), + new SmartyPluginDescriptor('function', 'currency', $this, 'currencyDataAccess'), + new SmartyPluginDescriptor('function', 'lang', $this, 'langDataAccess'), ); } } diff --git a/core/lib/Thelia/Core/TheliaHttpKernel.php b/core/lib/Thelia/Core/TheliaHttpKernel.php index 3c0f14808..319173f5f 100755 --- a/core/lib/Thelia/Core/TheliaHttpKernel.php +++ b/core/lib/Thelia/Core/TheliaHttpKernel.php @@ -135,9 +135,26 @@ class TheliaHttpKernel extends HttpKernel if ($lang) { $request->getSession() ->setLang($lang) - ->setLocale($lang->getLocale()) ; } + + $request->getSession()->setCurrency($this->defineCurrency($request)); + } + + protected function defineCurrency(Request $request) + { + $currency = null; + if ($request->query->has("currency")) { + $currency = Model\CurrencyQuery::create()->findOneByCode($request->query->get("currency")); + } else { + $currency = $request->getSession()->getCurrency(false); + } + + if(null === $currency) { + $currency = Model\Currency::getDefaultCurrency(); + } + + return $currency; } /** @@ -153,7 +170,7 @@ class TheliaHttpKernel extends HttpKernel $lang = Model\LangQuery::create()->findOneByCode($request->query->get("lang")); if (is_null($lang)) { - return; + return Model\Lang::getDefaultLanguage(); } //if each lang had is own domain, we redirect the user to the good one. @@ -175,7 +192,7 @@ class TheliaHttpKernel extends HttpKernel } //check if lang is not defined. If not we have to search the good one. - if (null === $request->getSession()->getLang()) { + if (null === $request->getSession()->getLang(false)) { if (Model\ConfigQuery::read("one_domain_foreach_lang", false) == 1) { //find lang with domain @@ -183,7 +200,7 @@ class TheliaHttpKernel extends HttpKernel } //find default lang - return Model\LangQuery::create()->findOneByByDefault(1); + return Model\Lang::getDefaultLanguage(); } } diff --git a/core/lib/Thelia/Core/Translation/Translator.php b/core/lib/Thelia/Core/Translation/Translator.php index d941fefb7..770091403 100755 --- a/core/lib/Thelia/Core/Translation/Translator.php +++ b/core/lib/Thelia/Core/Translation/Translator.php @@ -20,7 +20,7 @@ class Translator extends BaseTranslator * Return this class instance, only once instanciated. * * @throws \RuntimeException if the class has not been instanciated. - * @return Thelia\Core\Translation\Translator the instance. + * @return \Thelia\Core\Translation\Translator the instance. */ public static function getInstance() { if (self::$instance == null) throw new \RuntimeException("Translator instance is not initialized."); diff --git a/core/lib/Thelia/Form/BaseForm.php b/core/lib/Thelia/Form/BaseForm.php index 0eb6b828b..f15dd7525 100755 --- a/core/lib/Thelia/Form/BaseForm.php +++ b/core/lib/Thelia/Form/BaseForm.php @@ -102,6 +102,10 @@ abstract class BaseForm $this->formBuilder->add("success_url", "text"); } + if (! $this->formBuilder->has('error_message')) { + $this->formBuilder->add("error_message", "text"); + } + $this->form = $this->formBuilder->getForm(); } diff --git a/core/lib/Thelia/Form/CustomerLogin.php b/core/lib/Thelia/Form/CustomerLogin.php index 12b5a2775..3081ceed7 100755 --- a/core/lib/Thelia/Form/CustomerLogin.php +++ b/core/lib/Thelia/Form/CustomerLogin.php @@ -22,24 +22,38 @@ /*************************************************************************************/ namespace Thelia\Form; +use Symfony\Component\Validator\Constraints\Callback; use Symfony\Component\Validator\Constraints\NotBlank; use Symfony\Component\Validator\Constraints\Email; +use Symfony\Component\Validator\ExecutionContextInterface; +use Thelia\Core\Translation\Translator; +use Thelia\Model\CustomerQuery; class CustomerLogin extends BaseForm { protected function buildForm() { $this->formBuilder - ->add("email", "text", array( + ->add("email", "email", array( "constraints" => array( new NotBlank(), new Email() - ) + ), + "label" => Translator::getInstance()->trans("Please enter your email address"), + "label_attr" => array( + "for" => "email" + ), + "required" => true )) ->add("password", "password", array( "constraints" => array( new NotBlank() - ) + ), + "label" => Translator::getInstance()->trans("Please enter your password"), + "label_attr" => array( + "for" => "password" + ), + "required" => true )) ->add("remember_me", "checkbox") ; @@ -49,4 +63,5 @@ class CustomerLogin extends BaseForm { return "thelia_customer_login"; } + } diff --git a/core/lib/Thelia/Model/Currency.php b/core/lib/Thelia/Model/Currency.php index ef8d73735..843211d5a 100755 --- a/core/lib/Thelia/Model/Currency.php +++ b/core/lib/Thelia/Model/Currency.php @@ -13,6 +13,17 @@ class Currency extends BaseCurrency { use \Thelia\Model\Tools\PositionManagementTrait; + public static function getDefaultCurrency() + { + $currency = CurrencyQuery::create()->findOneByByDefault(1); + + if (null === $currency) { + throw new \RuntimeException("No default currency is defined. Please define one."); + } + + return $currency; + } + /** * {@inheritDoc} */ diff --git a/core/lib/Thelia/Tools/URL.php b/core/lib/Thelia/Tools/URL.php index e43591ffc..ffb81992d 100755 --- a/core/lib/Thelia/Tools/URL.php +++ b/core/lib/Thelia/Tools/URL.php @@ -121,6 +121,11 @@ class URL $base_url = $this->getBaseUrl(); + // TODO fix this ugly patch + if(strpos($path, "index_dev.php")) { + $path = str_replace('index_dev.php', '', $path); + } + // If only a path is requested, be sure to remove the script name (index.php or index_dev.php), if any. if ($path_only == self::PATH_TO_FILE) { // As the base_url always ends with '/', if we don't find / at the end, we have a script. diff --git a/templates/default/assets/css/plugins/bootstrap-magnify/bootstrap-magnify.css b/templates/default/assets/css/plugins/bootstrap-magnify/bootstrap-magnify.css new file mode 100755 index 000000000..a24a8e142 --- /dev/null +++ b/templates/default/assets/css/plugins/bootstrap-magnify/bootstrap-magnify.css @@ -0,0 +1,19 @@ +.magnify { + position: relative; + cursor: none +} + +.magnify-large { + position: absolute; + display: none; + width: 175px; + height: 175px; + + -webkit-box-shadow: 0 0 0 7px rgba(255, 255, 255, 0.85), 0 0 7px 7px rgba(0, 0, 0, 0.25), inset 0 0 40px 2px rgba(0, 0, 0, 0.25); + -moz-box-shadow: 0 0 0 7px rgba(255, 255, 255, 0.85), 0 0 7px 7px rgba(0, 0, 0, 0.25), inset 0 0 40px 2px rgba(0, 0, 0, 0.25); + box-shadow: 0 0 0 7px rgba(255, 255, 255, 0.85), 0 0 7px 7px rgba(0, 0, 0, 0.25), inset 0 0 40px 2px rgba(0, 0, 0, 0.25); + + -webkit-border-radius: 100%; + -moz-border-radius: 100%; + border-radius: 100% +} \ No newline at end of file diff --git a/templates/default/assets/css/plugins/bootstrap-magnify/bootstrap-magnify.min.css b/templates/default/assets/css/plugins/bootstrap-magnify/bootstrap-magnify.min.css new file mode 100755 index 000000000..15b9cc170 --- /dev/null +++ b/templates/default/assets/css/plugins/bootstrap-magnify/bootstrap-magnify.min.css @@ -0,0 +1 @@ +.magnify{position:relative;cursor:none}.magnify-large{position:absolute;display:none;width:175px;height:175px;-webkit-box-shadow:0 0 0 7px rgba(255,255,255,0.85),0 0 7px 7px rgba(0,0,0,0.25),inset 0 0 40px 2px rgba(0,0,0,0.25);-moz-box-shadow:0 0 0 7px rgba(255,255,255,0.85),0 0 7px 7px rgba(0,0,0,0.25),inset 0 0 40px 2px rgba(0,0,0,0.25);box-shadow:0 0 0 7px rgba(255,255,255,0.85),0 0 7px 7px rgba(0,0,0,0.25),inset 0 0 40px 2px rgba(0,0,0,0.25);-webkit-border-radius:100%;-moz-border-radius:100%;border-radius:100%} \ No newline at end of file diff --git a/templates/default/assets/font/bootstrap/glyphicons-halflings-regular.eot b/templates/default/assets/font/bootstrap/glyphicons-halflings-regular.eot new file mode 100755 index 000000000..87eaa4342 Binary files /dev/null and b/templates/default/assets/font/bootstrap/glyphicons-halflings-regular.eot differ diff --git a/templates/default/assets/font/bootstrap/glyphicons-halflings-regular.svg b/templates/default/assets/font/bootstrap/glyphicons-halflings-regular.svg new file mode 100755 index 000000000..5fee06854 --- /dev/null +++ b/templates/default/assets/font/bootstrap/glyphicons-halflings-regular.svg @@ -0,0 +1,228 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/templates/default/assets/font/bootstrap/glyphicons-halflings-regular.ttf b/templates/default/assets/font/bootstrap/glyphicons-halflings-regular.ttf new file mode 100755 index 000000000..be784dc1d Binary files /dev/null and b/templates/default/assets/font/bootstrap/glyphicons-halflings-regular.ttf differ diff --git a/templates/default/assets/font/bootstrap/glyphicons-halflings-regular.woff b/templates/default/assets/font/bootstrap/glyphicons-halflings-regular.woff new file mode 100755 index 000000000..2cc3e4852 Binary files /dev/null and b/templates/default/assets/font/bootstrap/glyphicons-halflings-regular.woff differ diff --git a/templates/default/assets/font/fontawesome/fontawesome-webfont.eot b/templates/default/assets/font/fontawesome/fontawesome-webfont.eot new file mode 100755 index 000000000..0662cb96b Binary files /dev/null and b/templates/default/assets/font/fontawesome/fontawesome-webfont.eot differ diff --git a/templates/default/assets/font/fontawesome/fontawesome-webfont.svg b/templates/default/assets/font/fontawesome/fontawesome-webfont.svg new file mode 100755 index 000000000..2edb4ec34 --- /dev/null +++ b/templates/default/assets/font/fontawesome/fontawesome-webfont.svg @@ -0,0 +1,399 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/templates/default/assets/font/fontawesome/fontawesome-webfont.ttf b/templates/default/assets/font/fontawesome/fontawesome-webfont.ttf new file mode 100755 index 000000000..d36592469 Binary files /dev/null and b/templates/default/assets/font/fontawesome/fontawesome-webfont.ttf differ diff --git a/templates/default/assets/font/fontawesome/fontawesome-webfont.woff b/templates/default/assets/font/fontawesome/fontawesome-webfont.woff new file mode 100755 index 000000000..b9bd17e15 Binary files /dev/null and b/templates/default/assets/font/fontawesome/fontawesome-webfont.woff differ diff --git a/templates/default/assets/img/218x146.png b/templates/default/assets/img/218x146.png new file mode 100644 index 000000000..07f043b12 Binary files /dev/null and b/templates/default/assets/img/218x146.png differ diff --git a/templates/default/assets/img/280x196.png b/templates/default/assets/img/280x196.png new file mode 100644 index 000000000..0df3c9403 Binary files /dev/null and b/templates/default/assets/img/280x196.png differ diff --git a/templates/default/assets/img/700x320.png b/templates/default/assets/img/700x320.png new file mode 100644 index 000000000..32c9edcb1 Binary files /dev/null and b/templates/default/assets/img/700x320.png differ diff --git a/templates/default/assets/img/carousel/1200x390.png b/templates/default/assets/img/carousel/1200x390.png new file mode 100644 index 000000000..2de73de49 Binary files /dev/null and b/templates/default/assets/img/carousel/1200x390.png differ diff --git a/templates/default/assets/img/carousel/slider1.png b/templates/default/assets/img/carousel/slider1.png new file mode 100644 index 000000000..422b3ddc0 Binary files /dev/null and b/templates/default/assets/img/carousel/slider1.png differ diff --git a/templates/default/assets/img/carousel/slider2.png b/templates/default/assets/img/carousel/slider2.png new file mode 100644 index 000000000..8eb4049b7 Binary files /dev/null and b/templates/default/assets/img/carousel/slider2.png differ diff --git a/templates/default/assets/img/carousel/slider3.png b/templates/default/assets/img/carousel/slider3.png new file mode 100644 index 000000000..b3630ff60 Binary files /dev/null and b/templates/default/assets/img/carousel/slider3.png differ diff --git a/templates/default/assets/img/logo.gif b/templates/default/assets/img/logo.gif new file mode 100644 index 000000000..cfa396641 Binary files /dev/null and b/templates/default/assets/img/logo.gif differ diff --git a/templates/default/assets/img/payment/american-express.png b/templates/default/assets/img/payment/american-express.png new file mode 100644 index 000000000..853b43dae Binary files /dev/null and b/templates/default/assets/img/payment/american-express.png differ diff --git a/templates/default/assets/img/payment/cheque.png b/templates/default/assets/img/payment/cheque.png new file mode 100644 index 000000000..16d83ba11 Binary files /dev/null and b/templates/default/assets/img/payment/cheque.png differ diff --git a/templates/default/assets/img/payment/kwixo.png b/templates/default/assets/img/payment/kwixo.png new file mode 100644 index 000000000..2055f9c8a Binary files /dev/null and b/templates/default/assets/img/payment/kwixo.png differ diff --git a/templates/default/assets/img/payment/mastercard.png b/templates/default/assets/img/payment/mastercard.png new file mode 100644 index 000000000..28701c3dd Binary files /dev/null and b/templates/default/assets/img/payment/mastercard.png differ diff --git a/templates/default/assets/img/payment/visa.png b/templates/default/assets/img/payment/visa.png new file mode 100644 index 000000000..ef0447105 Binary files /dev/null and b/templates/default/assets/img/payment/visa.png differ diff --git a/templates/default/assets/img/product/1/118x85.png b/templates/default/assets/img/product/1/118x85.png new file mode 100644 index 000000000..cf9e98b4a Binary files /dev/null and b/templates/default/assets/img/product/1/118x85.png differ diff --git a/templates/default/assets/img/product/1/560x445.png b/templates/default/assets/img/product/1/560x445.png new file mode 100644 index 000000000..37fea1775 Binary files /dev/null and b/templates/default/assets/img/product/1/560x445.png differ diff --git a/templates/default/assets/js/bootstrap/affix.js b/templates/default/assets/js/bootstrap/affix.js new file mode 100755 index 000000000..c7be96e1d --- /dev/null +++ b/templates/default/assets/js/bootstrap/affix.js @@ -0,0 +1,126 @@ +/* ======================================================================== + * Bootstrap: affix.js v3.0.0 + * http://twbs.github.com/bootstrap/javascript.html#affix + * ======================================================================== + * Copyright 2012 Twitter, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ======================================================================== */ + + ++function ($) { "use strict"; + + // AFFIX CLASS DEFINITION + // ====================== + + var Affix = function (element, options) { + this.options = $.extend({}, Affix.DEFAULTS, options) + this.$window = $(window) + .on('scroll.bs.affix.data-api', $.proxy(this.checkPosition, this)) + .on('click.bs.affix.data-api', $.proxy(this.checkPositionWithEventLoop, this)) + + this.$element = $(element) + this.affixed = + this.unpin = null + + this.checkPosition() + } + + Affix.RESET = 'affix affix-top affix-bottom' + + Affix.DEFAULTS = { + offset: 0 + } + + Affix.prototype.checkPositionWithEventLoop = function () { + setTimeout($.proxy(this.checkPosition, this), 1) + } + + Affix.prototype.checkPosition = function () { + if (!this.$element.is(':visible')) return + + var scrollHeight = $(document).height() + var scrollTop = this.$window.scrollTop() + var position = this.$element.offset() + var offset = this.options.offset + var offsetTop = offset.top + var offsetBottom = offset.bottom + + if (typeof offset != 'object') offsetBottom = offsetTop = offset + if (typeof offsetTop == 'function') offsetTop = offset.top() + if (typeof offsetBottom == 'function') offsetBottom = offset.bottom() + + var affix = this.unpin != null && (scrollTop + this.unpin <= position.top) ? false : + offsetBottom != null && (position.top + this.$element.height() >= scrollHeight - offsetBottom) ? 'bottom' : + offsetTop != null && (scrollTop <= offsetTop) ? 'top' : false + + if (this.affixed === affix) return + if (this.unpin) this.$element.css('top', '') + + this.affixed = affix + this.unpin = affix == 'bottom' ? position.top - scrollTop : null + + this.$element.removeClass(Affix.RESET).addClass('affix' + (affix ? '-' + affix : '')) + + if (affix == 'bottom') { + this.$element.offset({ top: document.body.offsetHeight - offsetBottom - this.$element.height() }) + } + } + + + // AFFIX PLUGIN DEFINITION + // ======================= + + var old = $.fn.affix + + $.fn.affix = function (option) { + return this.each(function () { + var $this = $(this) + var data = $this.data('bs.affix') + var options = typeof option == 'object' && option + + if (!data) $this.data('bs.affix', (data = new Affix(this, options))) + if (typeof option == 'string') data[option]() + }) + } + + $.fn.affix.Constructor = Affix + + + // AFFIX NO CONFLICT + // ================= + + $.fn.affix.noConflict = function () { + $.fn.affix = old + return this + } + + + // AFFIX DATA-API + // ============== + + $(window).on('load', function () { + $('[data-spy="affix"]').each(function () { + var $spy = $(this) + var data = $spy.data() + + data.offset = data.offset || {} + + if (data.offsetBottom) data.offset.bottom = data.offsetBottom + if (data.offsetTop) data.offset.top = data.offsetTop + + $spy.affix(data) + }) + }) + +}(window.jQuery); diff --git a/templates/default/assets/js/bootstrap/alert.js b/templates/default/assets/js/bootstrap/alert.js new file mode 100755 index 000000000..663029ed8 --- /dev/null +++ b/templates/default/assets/js/bootstrap/alert.js @@ -0,0 +1,98 @@ +/* ======================================================================== + * Bootstrap: alert.js v3.0.0 + * http://twbs.github.com/bootstrap/javascript.html#alerts + * ======================================================================== + * Copyright 2013 Twitter, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ======================================================================== */ + + ++function ($) { "use strict"; + + // ALERT CLASS DEFINITION + // ====================== + + var dismiss = '[data-dismiss="alert"]' + var Alert = function (el) { + $(el).on('click', dismiss, this.close) + } + + Alert.prototype.close = function (e) { + var $this = $(this) + var selector = $this.attr('data-target') + + if (!selector) { + selector = $this.attr('href') + selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') // strip for ie7 + } + + var $parent = $(selector) + + if (e) e.preventDefault() + + if (!$parent.length) { + $parent = $this.hasClass('alert') ? $this : $this.parent() + } + + $parent.trigger(e = $.Event('close.bs.alert')) + + if (e.isDefaultPrevented()) return + + $parent.removeClass('in') + + function removeElement() { + $parent.trigger('closed.bs.alert').remove() + } + + $.support.transition && $parent.hasClass('fade') ? + $parent + .one($.support.transition.end, removeElement) + .emulateTransitionEnd(150) : + removeElement() + } + + + // ALERT PLUGIN DEFINITION + // ======================= + + var old = $.fn.alert + + $.fn.alert = function (option) { + return this.each(function () { + var $this = $(this) + var data = $this.data('bs.alert') + + if (!data) $this.data('bs.alert', (data = new Alert(this))) + if (typeof option == 'string') data[option].call($this) + }) + } + + $.fn.alert.Constructor = Alert + + + // ALERT NO CONFLICT + // ================= + + $.fn.alert.noConflict = function () { + $.fn.alert = old + return this + } + + + // ALERT DATA-API + // ============== + + $(document).on('click.bs.alert.data-api', dismiss, Alert.prototype.close) + +}(window.jQuery); diff --git a/templates/default/assets/js/bootstrap/button.js b/templates/default/assets/js/bootstrap/button.js new file mode 100755 index 000000000..fc73b555f --- /dev/null +++ b/templates/default/assets/js/bootstrap/button.js @@ -0,0 +1,109 @@ +/* ======================================================================== + * Bootstrap: button.js v3.0.0 + * http://twbs.github.com/bootstrap/javascript.html#buttons + * ======================================================================== + * Copyright 2013 Twitter, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ======================================================================== */ + + ++function ($) { "use strict"; + + // BUTTON PUBLIC CLASS DEFINITION + // ============================== + + var Button = function (element, options) { + this.$element = $(element) + this.options = $.extend({}, Button.DEFAULTS, options) + } + + Button.DEFAULTS = { + loadingText: 'loading...' + } + + Button.prototype.setState = function (state) { + var d = 'disabled' + var $el = this.$element + var val = $el.is('input') ? 'val' : 'html' + var data = $el.data() + + state = state + 'Text' + + if (!data.resetText) $el.data('resetText', $el[val]()) + + $el[val](data[state] || this.options[state]) + + // push to event loop to allow forms to submit + setTimeout(function () { + state == 'loadingText' ? + $el.addClass(d).attr(d, d) : + $el.removeClass(d).removeAttr(d); + }, 0) + } + + Button.prototype.toggle = function () { + var $parent = this.$element.closest('[data-toggle="buttons"]') + + if ($parent.length) { + var $input = this.$element.find('input') + .prop('checked', !this.$element.hasClass('active')) + .trigger('change') + if ($input.prop('type') === 'radio') $parent.find('.active').removeClass('active') + } + + this.$element.toggleClass('active') + } + + + // BUTTON PLUGIN DEFINITION + // ======================== + + var old = $.fn.button + + $.fn.button = function (option) { + return this.each(function () { + var $this = $(this) + var data = $this.data('bs.button') + var options = typeof option == 'object' && option + + if (!data) $this.data('bs.button', (data = new Button(this, options))) + + if (option == 'toggle') data.toggle() + else if (option) data.setState(option) + }) + } + + $.fn.button.Constructor = Button + + + // BUTTON NO CONFLICT + // ================== + + $.fn.button.noConflict = function () { + $.fn.button = old + return this + } + + + // BUTTON DATA-API + // =============== + + $(document).on('click.bs.button.data-api', '[data-toggle^=button]', function (e) { + var $btn = $(e.target) + if (!$btn.hasClass('btn')) $btn = $btn.closest('.btn') + $btn.button('toggle') + e.preventDefault() + }) + +}(window.jQuery); diff --git a/templates/default/assets/js/bootstrap/carousel.js b/templates/default/assets/js/bootstrap/carousel.js new file mode 100755 index 000000000..d8c4c243c --- /dev/null +++ b/templates/default/assets/js/bootstrap/carousel.js @@ -0,0 +1,217 @@ +/* ======================================================================== + * Bootstrap: carousel.js v3.0.0 + * http://twbs.github.com/bootstrap/javascript.html#carousel + * ======================================================================== + * Copyright 2012 Twitter, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ======================================================================== */ + + ++function ($) { "use strict"; + + // CAROUSEL CLASS DEFINITION + // ========================= + + var Carousel = function (element, options) { + this.$element = $(element) + this.$indicators = this.$element.find('.carousel-indicators') + this.options = options + this.paused = + this.sliding = + this.interval = + this.$active = + this.$items = null + + this.options.pause == 'hover' && this.$element + .on('mouseenter', $.proxy(this.pause, this)) + .on('mouseleave', $.proxy(this.cycle, this)) + } + + Carousel.DEFAULTS = { + interval: 5000 + , pause: 'hover' + , wrap: true + } + + Carousel.prototype.cycle = function (e) { + e || (this.paused = false) + + this.interval && clearInterval(this.interval) + + this.options.interval + && !this.paused + && (this.interval = setInterval($.proxy(this.next, this), this.options.interval)) + + return this + } + + Carousel.prototype.getActiveIndex = function () { + this.$active = this.$element.find('.item.active') + this.$items = this.$active.parent().children() + + return this.$items.index(this.$active) + } + + Carousel.prototype.to = function (pos) { + var that = this + var activeIndex = this.getActiveIndex() + + if (pos > (this.$items.length - 1) || pos < 0) return + + if (this.sliding) return this.$element.one('slid', function () { that.to(pos) }) + if (activeIndex == pos) return this.pause().cycle() + + return this.slide(pos > activeIndex ? 'next' : 'prev', $(this.$items[pos])) + } + + Carousel.prototype.pause = function (e) { + e || (this.paused = true) + + if (this.$element.find('.next, .prev').length && $.support.transition.end) { + this.$element.trigger($.support.transition.end) + this.cycle(true) + } + + this.interval = clearInterval(this.interval) + + return this + } + + Carousel.prototype.next = function () { + if (this.sliding) return + return this.slide('next') + } + + Carousel.prototype.prev = function () { + if (this.sliding) return + return this.slide('prev') + } + + Carousel.prototype.slide = function (type, next) { + var $active = this.$element.find('.item.active') + var $next = next || $active[type]() + var isCycling = this.interval + var direction = type == 'next' ? 'left' : 'right' + var fallback = type == 'next' ? 'first' : 'last' + var that = this + + if (!$next.length) { + if (!this.options.wrap) return + $next = this.$element.find('.item')[fallback]() + } + + this.sliding = true + + isCycling && this.pause() + + var e = $.Event('slide.bs.carousel', { relatedTarget: $next[0], direction: direction }) + + if ($next.hasClass('active')) return + + if (this.$indicators.length) { + this.$indicators.find('.active').removeClass('active') + this.$element.one('slid', function () { + var $nextIndicator = $(that.$indicators.children()[that.getActiveIndex()]) + $nextIndicator && $nextIndicator.addClass('active') + }) + } + + if ($.support.transition && this.$element.hasClass('slide')) { + this.$element.trigger(e) + if (e.isDefaultPrevented()) return + $next.addClass(type) + $next[0].offsetWidth // force reflow + $active.addClass(direction) + $next.addClass(direction) + $active + .one($.support.transition.end, function () { + $next.removeClass([type, direction].join(' ')).addClass('active') + $active.removeClass(['active', direction].join(' ')) + that.sliding = false + setTimeout(function () { that.$element.trigger('slid') }, 0) + }) + .emulateTransitionEnd(600) + } else { + this.$element.trigger(e) + if (e.isDefaultPrevented()) return + $active.removeClass('active') + $next.addClass('active') + this.sliding = false + this.$element.trigger('slid') + } + + isCycling && this.cycle() + + return this + } + + + // CAROUSEL PLUGIN DEFINITION + // ========================== + + var old = $.fn.carousel + + $.fn.carousel = function (option) { + return this.each(function () { + var $this = $(this) + var data = $this.data('bs.carousel') + var options = $.extend({}, Carousel.DEFAULTS, $this.data(), typeof option == 'object' && option) + var action = typeof option == 'string' ? option : options.slide + + if (!data) $this.data('bs.carousel', (data = new Carousel(this, options))) + if (typeof option == 'number') data.to(option) + else if (action) data[action]() + else if (options.interval) data.pause().cycle() + }) + } + + $.fn.carousel.Constructor = Carousel + + + // CAROUSEL NO CONFLICT + // ==================== + + $.fn.carousel.noConflict = function () { + $.fn.carousel = old + return this + } + + + // CAROUSEL DATA-API + // ================= + + $(document).on('click.bs.carousel.data-api', '[data-slide], [data-slide-to]', function (e) { + var $this = $(this), href + var $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7 + var options = $.extend({}, $target.data(), $this.data()) + var slideIndex = $this.attr('data-slide-to') + if (slideIndex) options.interval = false + + $target.carousel(options) + + if (slideIndex = $this.attr('data-slide-to')) { + $target.data('bs.carousel').to(slideIndex) + } + + e.preventDefault() + }) + + $(window).on('load', function () { + $('[data-ride="carousel"]').each(function () { + var $carousel = $(this) + $carousel.carousel($carousel.data()) + }) + }) + +}(window.jQuery); diff --git a/templates/default/assets/js/bootstrap/collapse.js b/templates/default/assets/js/bootstrap/collapse.js new file mode 100755 index 000000000..92cc0bc76 --- /dev/null +++ b/templates/default/assets/js/bootstrap/collapse.js @@ -0,0 +1,179 @@ +/* ======================================================================== + * Bootstrap: collapse.js v3.0.0 + * http://twbs.github.com/bootstrap/javascript.html#collapse + * ======================================================================== + * Copyright 2012 Twitter, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ======================================================================== */ + + ++function ($) { "use strict"; + + // COLLAPSE PUBLIC CLASS DEFINITION + // ================================ + + var Collapse = function (element, options) { + this.$element = $(element) + this.options = $.extend({}, Collapse.DEFAULTS, options) + this.transitioning = null + + if (this.options.parent) this.$parent = $(this.options.parent) + if (this.options.toggle) this.toggle() + } + + Collapse.DEFAULTS = { + toggle: true + } + + Collapse.prototype.dimension = function () { + var hasWidth = this.$element.hasClass('width') + return hasWidth ? 'width' : 'height' + } + + Collapse.prototype.show = function () { + if (this.transitioning || this.$element.hasClass('in')) return + + var startEvent = $.Event('show.bs.collapse') + this.$element.trigger(startEvent) + if (startEvent.isDefaultPrevented()) return + + var actives = this.$parent && this.$parent.find('> .panel > .in') + + if (actives && actives.length) { + var hasData = actives.data('bs.collapse') + if (hasData && hasData.transitioning) return + actives.collapse('hide') + hasData || actives.data('bs.collapse', null) + } + + var dimension = this.dimension() + + this.$element + .removeClass('collapse') + .addClass('collapsing') + [dimension](0) + + this.transitioning = 1 + + var complete = function () { + this.$element + .removeClass('collapsing') + .addClass('in') + [dimension]('auto') + this.transitioning = 0 + this.$element.trigger('shown.bs.collapse') + } + + if (!$.support.transition) return complete.call(this) + + var scrollSize = $.camelCase(['scroll', dimension].join('-')) + + this.$element + .one($.support.transition.end, $.proxy(complete, this)) + .emulateTransitionEnd(350) + [dimension](this.$element[0][scrollSize]) + } + + Collapse.prototype.hide = function () { + if (this.transitioning || !this.$element.hasClass('in')) return + + var startEvent = $.Event('hide.bs.collapse') + this.$element.trigger(startEvent) + if (startEvent.isDefaultPrevented()) return + + var dimension = this.dimension() + + this.$element + [dimension](this.$element[dimension]()) + [0].offsetHeight + + this.$element + .addClass('collapsing') + .removeClass('collapse') + .removeClass('in') + + this.transitioning = 1 + + var complete = function () { + this.transitioning = 0 + this.$element + .trigger('hidden.bs.collapse') + .removeClass('collapsing') + .addClass('collapse') + } + + if (!$.support.transition) return complete.call(this) + + this.$element + [dimension](0) + .one($.support.transition.end, $.proxy(complete, this)) + .emulateTransitionEnd(350) + } + + Collapse.prototype.toggle = function () { + this[this.$element.hasClass('in') ? 'hide' : 'show']() + } + + + // COLLAPSE PLUGIN DEFINITION + // ========================== + + var old = $.fn.collapse + + $.fn.collapse = function (option) { + return this.each(function () { + var $this = $(this) + var data = $this.data('bs.collapse') + var options = $.extend({}, Collapse.DEFAULTS, $this.data(), typeof option == 'object' && option) + + if (!data) $this.data('bs.collapse', (data = new Collapse(this, options))) + if (typeof option == 'string') data[option]() + }) + } + + $.fn.collapse.Constructor = Collapse + + + // COLLAPSE NO CONFLICT + // ==================== + + $.fn.collapse.noConflict = function () { + $.fn.collapse = old + return this + } + + + // COLLAPSE DATA-API + // ================= + + $(document).on('click.bs.collapse.data-api', '[data-toggle=collapse]', function (e) { + var $this = $(this), href + var target = $this.attr('data-target') + || e.preventDefault() + || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '') //strip for ie7 + var $target = $(target) + var data = $target.data('bs.collapse') + var option = data ? 'toggle' : $this.data() + var parent = $this.attr('data-parent') + var $parent = parent && $(parent) + + if (!data || !data.transitioning) { + if ($parent) $parent.find('[data-toggle=collapse][data-parent="' + parent + '"]').not($this).addClass('collapsed') + $this[$target.hasClass('in') ? 'addClass' : 'removeClass']('collapsed') + } + + $target.collapse(option) + }) + +}(window.jQuery); diff --git a/templates/default/assets/js/bootstrap/dropdown.js b/templates/default/assets/js/bootstrap/dropdown.js new file mode 100755 index 000000000..6093f11a8 --- /dev/null +++ b/templates/default/assets/js/bootstrap/dropdown.js @@ -0,0 +1,154 @@ +/* ======================================================================== + * Bootstrap: dropdown.js v3.0.0 + * http://twbs.github.com/bootstrap/javascript.html#dropdowns + * ======================================================================== + * Copyright 2012 Twitter, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ======================================================================== */ + + ++function ($) { "use strict"; + + // DROPDOWN CLASS DEFINITION + // ========================= + + var backdrop = '.dropdown-backdrop' + var toggle = '[data-toggle=dropdown]' + var Dropdown = function (element) { + var $el = $(element).on('click.bs.dropdown', this.toggle) + } + + Dropdown.prototype.toggle = function (e) { + var $this = $(this) + + if ($this.is('.disabled, :disabled')) return + + var $parent = getParent($this) + var isActive = $parent.hasClass('open') + + clearMenus() + + if (!isActive) { + if ('ontouchstart' in document.documentElement && !$parent.closest('.navbar-nav').length) { + // if mobile we we use a backdrop because click events don't delegate + $('