magalter-fastlogin - Version 1.0.0.2

Version Notes

1.0.0.2

Download this release

Release Info

Developer Magalter
Extension magalter-fastlogin
Version 1.0.0.2
Comparing to
See all releases


Version 1.0.0.2

app/code/local/Magalter/Fastlogin/Block/Login.php ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Magalter_Fastlogin_Block_Login extends Mage_Core_Block_Template {
4
+
5
+ private $_enabled = 'fastlogin/configuration/enable';
6
+ private $_ajaxAllowed = 'fastlogin/configuration/enableajax';
7
+ private $_hideForm = 'fastlogin/configuration/hideform';
8
+ private $_headerForm = 'fastlogin/configuration/headerform';
9
+ private $_cartSideBar = 'fastlogin/configuration/cartsidebar';
10
+ private $_horizontalPos = 'fastlogin/configuration/horizontal';
11
+ private $_verticalPos = 'fastlogin/configuration/vertical';
12
+
13
+ protected function _toHtml() {
14
+
15
+ if ($this->checkConfig($this->_enabled)) {
16
+
17
+ if (isset($this->_data['position']) || $this->checkConfig($this->_headerForm)) {
18
+
19
+ if ($this->checkConfig($this->_hideForm)) {
20
+ $this->setData('hideForm', '1');
21
+ }
22
+ if ($this->checkConfig($this->_ajaxAllowed)) {
23
+ $this->setData('ajaxEnabled', '1');
24
+ }
25
+ if ($this->checkConfig($this->_cartSideBar)) {
26
+ $this->setData('cartSideBar', '1');
27
+ }
28
+
29
+ /* Horizontal and vertical corrections */
30
+ if ($hp = $this->checkConfig($this->_horizontalPos, true)) {
31
+ if ((int) $hp) {
32
+ $this->setData('horizontal_correction', $hp);
33
+ }
34
+ }
35
+ if ($vp = $this->checkConfig($this->_verticalPos, true)) {
36
+ if ((int) $vp) {
37
+ $this->setData('vertical_correction', $vp);
38
+ }
39
+ }
40
+
41
+ $this->setTemplate('magalter_fastlogin/headerlogin.phtml');
42
+
43
+ return parent::_toHtml();
44
+ }
45
+ }
46
+ }
47
+
48
+ protected function _prepareLayout() {
49
+ if($layout = $this->getLayout()) {
50
+ if(Mage::getSingleton('customer/session')->getCustomer()->getId()) {
51
+ $topLinksBlock = $layout->getBlock('top.links');
52
+ if(is_object($topLinksBlock)) { $topLinksBlock->removeLinkByUrl(Mage::getUrl('customer/account/create')); }
53
+ }
54
+ }
55
+ }
56
+
57
+
58
+ private function checkConfig($configPath, $value = false) {
59
+
60
+ if ($value) {
61
+ return Mage::getStoreConfig($configPath);
62
+ }
63
+
64
+ if (Mage::getStoreConfig($configPath)) {
65
+ return true;
66
+ }
67
+
68
+ return false;
69
+ }
70
+
71
+ }
72
+
73
+ ?>
app/code/local/Magalter/Fastlogin/Block/LogoutLink.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+ class Magalter_Fastlogin_Block_LogoutLink extends Mage_Core_Block_Template
5
+ {
6
+
7
+ protected function _toHtml() {
8
+
9
+
10
+ $this->setTemplate('magalter_fastlogin/logoutlink.phtml');
11
+ return parent::_toHtml();
12
+
13
+
14
+ }
15
+
16
+
17
+
18
+
19
+ }
app/code/local/Magalter/Fastlogin/Helper/Data.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+ class Magalter_Fastlogin_Helper_Data extends Mage_Core_Helper_Abstract
5
+ {
6
+
7
+
8
+ }
app/code/local/Magalter/Fastlogin/controllers/AccountController.php ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+ class Magalter_Fastlogin_AccountController extends Mage_Core_Controller_Front_Action
5
+ {
6
+
7
+ public function loginPostAction() {
8
+
9
+ $this->loadLayout();
10
+ $session = Mage::getSingleton('customer/session');
11
+ $request = $this->getRequest();
12
+ $userName = $request->getParam('userEmail');
13
+ $userPassword = $request->getParam('userPassword');
14
+
15
+ try {
16
+
17
+ $session->login($userName, $userPassword);
18
+ $jsonData = $this->getTopLinksJson();
19
+ echo "{".$jsonData."}";
20
+
21
+ } catch (Mage_Core_Exception $e) {
22
+ switch ($e->getCode()) {
23
+ case Mage_Customer_Model_Customer::EXCEPTION_EMAIL_NOT_CONFIRMED:
24
+ $message = Mage::helper('customer')->__('This account is not confirmed. <a href="%s">Click here</a> to resend confirmation email.', Mage::helper('customer')->getEmailConfirmationUrl($userName));
25
+ break;
26
+ case Mage_Customer_Model_Customer::EXCEPTION_INVALID_EMAIL_OR_PASSWORD:
27
+ $message = $e->getMessage();
28
+ break;
29
+ default: break;
30
+ }
31
+ } catch (Exception $e) { }
32
+ $session->setUsername($userName);
33
+ echo $message;
34
+ }
35
+
36
+ private function getTopLinksJson() {
37
+
38
+ $cartLink = $this->getTopLinksText(
39
+ Mage::helper('checkout/cart')->getSummaryCount(),
40
+ $this->__("My cart"));
41
+
42
+ if(Mage::helper('wishlist')->isAllow()) {
43
+ $wishlistLink = $this->getTopLinksText(
44
+ Mage::helper('wishlist')->getItemCount(),
45
+ $this->__("My wishlist")
46
+ );
47
+ }
48
+ else {
49
+ $wishlistLink = $this->__("My wishlist");
50
+ }
51
+
52
+ $logOutLink = $this->getLayout()->createBlock('fastlogin/logoutLink')->toHtml();
53
+ $welcome = $this->__('Welcome, %s!', htmlspecialchars(Mage::getSingleton('customer/session')->getCustomer()->getName()));
54
+
55
+ $sideBar = $this->getLayout()->getBlock('cart_sidebar')->toHtml();
56
+
57
+ $json = $this->jsonEncode('cartLink',$cartLink,$sep = '');
58
+ $json .= $this->jsonEncode('wishlistLink',$wishlistLink);
59
+ $json .= $this->jsonEncode('logoutLink',$logOutLink);
60
+ $json .= $this->jsonEncode('welcome',$welcome);
61
+ $json .= $this->jsonEncode('action','redirect');
62
+ $json .= $this->jsonEncode('sideBar',$sideBar);
63
+
64
+ return $json;
65
+
66
+ }
67
+
68
+
69
+ private function jsonEncode($key,$data,$sep=',') {
70
+ return "$sep\"$key\":".Zend_Json_Encoder::encode($data);
71
+ }
72
+
73
+ private function getTopLinksText($count,$position) {
74
+ if( $count == 1 ) {
75
+ $text = $this->__("$position (%s item)", $count);
76
+ } elseif( $count > 0 ) {
77
+ $text = $this->__("$position (%s items)", $count);
78
+ } else {
79
+ $text = $this->__("$position");
80
+ }
81
+ return $text;
82
+ }
83
+
84
+ }
app/code/local/Magalter/Fastlogin/etc/adminhtml.xml ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+
3
+ <config>
4
+ <acl>
5
+ <resources>
6
+ <all>
7
+ <title>Allow Everything</title>
8
+ </all>
9
+ <admin>
10
+ <children>
11
+ <system>
12
+ <children>
13
+ <config>
14
+ <children>
15
+ <fastlogin>
16
+ <title>Fast login</title>
17
+ </fastlogin>
18
+ </children>
19
+ </config>
20
+ </children>
21
+ </system>
22
+ </children>
23
+ </admin>
24
+ </resources>
25
+ </acl>
26
+ </config>
27
+
28
+
29
+
30
+
31
+
32
+
app/code/local/Magalter/Fastlogin/etc/config.xml ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Magalter_Fastlogin>
5
+ <version>1.0.0.1</version>
6
+ </Magalter_Fastlogin>
7
+ </modules>
8
+
9
+ <frontend>
10
+ <translate>
11
+ <modules>
12
+ <Magalter_Fastlogin>
13
+ <files>
14
+ <default>Magalter_Fastlogin.csv</default>
15
+ </files>
16
+ </Magalter_Fastlogin>
17
+ </modules>
18
+ </translate>
19
+ <routers>
20
+ <fastlogin>
21
+ <use>standard</use>
22
+ <args>
23
+ <module>Magalter_Fastlogin</module>
24
+ <frontName>fastlogin</frontName>
25
+ </args>
26
+ </fastlogin>
27
+ </routers>
28
+ <layout>
29
+ <updates>
30
+ <fastlogin>
31
+ <file>magalter_fastlogin.xml</file>
32
+ </fastlogin>
33
+ </updates>
34
+ </layout>
35
+ </frontend>
36
+
37
+ <adminhtml>
38
+ <translate>
39
+ <modules>
40
+ <Magalter_Fastlogin>
41
+ <files>
42
+ <default>Magalter_Ajaxlogin.csv</default>
43
+ </files>
44
+ </Magalter_Fastlogin>
45
+ </modules>
46
+ </translate>
47
+ <layout>
48
+ <updates>
49
+ <fastlogin>
50
+ <file>magalter_fastlogin.xml</file>
51
+ </fastlogin>
52
+ </updates>
53
+ </layout>
54
+ </adminhtml>
55
+
56
+ <global>
57
+ <resources>
58
+ <fastlogin_write>
59
+ <connection>
60
+ <use>core_write</use>
61
+ </connection>
62
+ </fastlogin_write>
63
+ <fastlogin_read>
64
+ <connection>
65
+ <use>core_read</use>
66
+ </connection>
67
+ </fastlogin_read>
68
+ </resources>
69
+ <blocks>
70
+ <fastlogin>
71
+ <class>Magalter_Fastlogin_Block</class>
72
+ </fastlogin>
73
+ </blocks>
74
+ <models>
75
+ <fastlogin>
76
+ <class>Magalter_Fastlogin_Model</class>
77
+ </fastlogin>
78
+ </models>
79
+ <helpers>
80
+ <fastlogin>
81
+ <class>Magalter_Fastlogin_Helper</class>
82
+ </fastlogin>
83
+ </helpers>
84
+ </global>
85
+ </config>
app/code/local/Magalter/Fastlogin/etc/system.xml ADDED
@@ -0,0 +1,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <sections>
4
+ <fastlogin translate="label" module="fastlogin">
5
+ <label>Fast login</label>
6
+ <tab>magalter</tab>
7
+ <sort_order>10</sort_order>
8
+ <show_in_default>1</show_in_default>
9
+ <show_in_website>1</show_in_website>
10
+ <show_in_store>1</show_in_store>
11
+
12
+ <groups>
13
+ <configuration translate="label">
14
+ <label>General settings</label>
15
+ <sort_order>2</sort_order>
16
+ <show_in_default>1</show_in_default>
17
+ <show_in_website>1</show_in_website>
18
+ <show_in_store>1</show_in_store>
19
+ <fields>
20
+ <enable translate="label">
21
+ <label>Enable</label>
22
+ <frontend_type>select</frontend_type>
23
+ <source_model>adminhtml/system_config_source_Yesno</source_model>
24
+ <sort_order>1</sort_order>
25
+ <show_in_default>1</show_in_default>
26
+ <show_in_website>1</show_in_website>
27
+ <show_in_store>1</show_in_store>
28
+ </enable>
29
+ <enableajax translate="label">
30
+ <label>Enable ajax</label>
31
+ <frontend_type>select</frontend_type>
32
+ <comment>Note, on login failure user will be redirected to native Magento login form</comment>
33
+ <source_model>adminhtml/system_config_source_Yesno</source_model>
34
+ <sort_order>2</sort_order>
35
+ <show_in_default>1</show_in_default>
36
+ <show_in_website>1</show_in_website>
37
+ <show_in_store>1</show_in_store>
38
+ </enableajax>
39
+ <headerform translate="label">
40
+ <label>Show login form in header</label>
41
+ <frontend_type>select</frontend_type>
42
+ <comment>If this option is set to "No", fast login form should be inserted manually in phtml files </comment>
43
+ <source_model>adminhtml/system_config_source_Yesno</source_model>
44
+ <sort_order>3</sort_order>
45
+ <show_in_default>1</show_in_default>
46
+ <show_in_website>1</show_in_website>
47
+ <show_in_store>1</show_in_store>
48
+ </headerform>
49
+ <horizontal translate="label">
50
+ <label>Horizontal position corrections</label>
51
+ <frontend_type>text</frontend_type>
52
+ <comment>Use negative values to move block to the left and positive to move block to the right</comment>
53
+ <sort_order>4</sort_order>
54
+ <show_in_default>1</show_in_default>
55
+ <show_in_website>1</show_in_website>
56
+ <show_in_store>1</show_in_store>
57
+ </horizontal>
58
+ <vertical translate="label">
59
+ <label>Vertical position corrections</label>
60
+ <frontend_type>text</frontend_type>
61
+ <comment>Use negative values to move block upper and positive to move lower</comment>
62
+ <sort_order>5</sort_order>
63
+ <show_in_default>1</show_in_default>
64
+ <show_in_website>1</show_in_website>
65
+ <show_in_store>1</show_in_store>
66
+ </vertical>
67
+
68
+ <hideform translate="label">
69
+ <label>Hide login form</label>
70
+ <frontend_type>select</frontend_type>
71
+ <source_model>adminhtml/system_config_source_Yesno</source_model>
72
+ <comment>Login form will not show up until user has clicked "Login" link</comment>
73
+ <sort_order>6</sort_order>
74
+ <show_in_default>1</show_in_default>
75
+ <show_in_website>1</show_in_website>
76
+ <show_in_store>1</show_in_store>
77
+ </hideform>
78
+ <cartsidebar translate="label">
79
+ <label>Update cart sidebar</label>
80
+ <frontend_type>select</frontend_type>
81
+ <source_model>adminhtml/system_config_source_Yesno</source_model>
82
+ <comment>May slow down performance (Beta)</comment>
83
+ <sort_order>7</sort_order>
84
+ <show_in_default>1</show_in_default>
85
+ <show_in_website>1</show_in_website>
86
+ <show_in_store>1</show_in_store>
87
+ </cartsidebar>
88
+ </fields>
89
+ </configuration>
90
+ </groups>
91
+ </fastlogin>
92
+ </sections>
93
+
94
+ </config>
app/design/frontend/default/default/layout/magalter_fastlogin.xml ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout version="0.1.0">
3
+ <default>
4
+ <reference name = "head">
5
+ <action method="addCss" ifconfig="fastlogin/configuration/enable"><stylesheet>magalter_fastlogin/styles.css</stylesheet></action>
6
+ <action method="addJs" ifconfig="fastlogin/configuration/enable"><script>magalter_fastlogin/form.js</script></action>
7
+ </reference>
8
+ <reference name = "top.links">
9
+ <action method = "addLink"><label>Register</label><url>customer/account/create/</url><title>Register</title><prepare>true</prepare></action>
10
+ </reference>
11
+ <reference name = "before_body_end">
12
+ <block type = "fastlogin/login" name="ajaxlogin_form" as="ajaxlogin_form" template = "magalter_fastlogin/headerlogin.phtml" />
13
+ </reference>
14
+ </default>
15
+ </layout>
app/design/frontend/default/default/template/magalter_fastlogin/headerlogin.phtml ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php if(!Mage::getSingleton('customer/session')->getCustomer()->getId()):?>
2
+ <div id = "ajax_login_wrapper" <?php
3
+
4
+ if($this->getData('hideForm') == 1) {
5
+ echo "style = 'display:none;';";
6
+ }
7
+ ?>>
8
+ <div id = "ajax_login_contents">
9
+ <ul class="messages" id ="ajax_login_wrapper_ul" style = "text-align:left;"><li class="error-msg"><ul><li><span id = "do-err-messages"></span></li></ul></li></ul>
10
+ <form action="<?php echo Mage_Customer_Block_Form_Login::getPostActionUrl() ?>" onsubmit="return ajaxloginForm.getClass().validateForm();" method="post" id = "do_ajaxlogin_form">
11
+ <div id = "float1">
12
+ <input type="text" name="login[username]" value = "<?php echo $this->__('Login email') ?>" id="do-mini-login" class="input-text required-entry validate-email" />
13
+ </div>
14
+ <div id = "float2">
15
+ <input type="password" name="login[password]" id="do-mini-password" class="input-text required-entry validate-password" value = "<?php echo $this->__('Login password') ?>" />
16
+ </div>
17
+ <div class="actions">
18
+ <button type="submit" class="button fastloginButton"><span><?php echo $this->__('Login') ?></span></button>
19
+ </div>
20
+ </form>
21
+ </div>
22
+ <div id = "ajaxlogin_loader_holder" style = "display:none;"></div>
23
+ </div>
24
+
25
+ <img id = "ajaxlogin_loader_cache" src = "<?php echo Mage::getModel('core/design_package')->getSkinUrl('images/ajaxlog_loader.gif'); ?>" />
26
+
27
+
28
+ <?php endif; ?>
29
+ <script type = "text/javascript">
30
+ document.observe("dom:loaded", function() {
31
+ <?php
32
+ if($this->getData('ajaxEnabled') != 1) {
33
+ echo "ajaxloginForm.ajax = false;";
34
+ }
35
+ if($this->getData('hideForm') != 1) {
36
+ echo "ajaxloginForm.hideForm = false;";
37
+ }
38
+ if($this->getData('cartSideBar') != 1) {
39
+ echo "ajaxloginForm.cartSidebar = false;";
40
+ }
41
+ if(isset($this->_data['position'])) {
42
+ echo "ajaxloginForm.computePosition = false;";
43
+ }
44
+
45
+ if($this->getData('horizontal_correction')) {
46
+ echo "ajaxloginForm.horizontalCorrection = '{$this->getHorizontalCorrection()}';";
47
+ }
48
+ if($this->getData('vertical_correction')) {
49
+ echo "ajaxloginForm.verticalCorrection = '{$this->getVerticalCorrection()}';";
50
+ }
51
+
52
+
53
+ ?>
54
+ ajaxloginForm.init('do_ajaxlogin_form');
55
+ ajaxloginForm.getClass().computeBlockPosition('ajax_login_wrapper');
56
+
57
+
58
+ Event.observe(document.body, 'click', function(event) {
59
+ var element = Event.element(event);
60
+ if(!Object.isElement(element.up('#ajax_login_wrapper'))) {
61
+ if($('ajax_login_wrapper').getStyle('display') == 'block') {
62
+ Effect.toggle($('ajax_login_wrapper'),'appear');
63
+ }
64
+ }
65
+ });
66
+
67
+
68
+
69
+ });
70
+ </script>
app/design/frontend/default/default/template/magalter_fastlogin/logoutlink.phtml ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $urlHelper = new Mage_Customer_Helper_Data();
4
+ $url = $urlHelper->getLogoutUrl();
5
+ ?>
6
+
7
+ <a title = "<?php echo $this->__('Log out') ?>" href = "<?php echo $url ?>"><?php echo $this->__("Log out") ?></a>
app/etc/modules/Magalter_Fastlogin.xml ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <config>
2
+ <modules>
3
+ <Magalter_Fastlogin>
4
+ <active>true</active>
5
+ <codePool>local</codePool>
6
+ </Magalter_Fastlogin>
7
+ </modules>
8
+ </config>
app/locale/en_US/Magalter_Fastlogin.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ "Login email","Login"
2
+ "Login password","Password"
3
+
js/magalter_fastlogin/form.js ADDED
@@ -0,0 +1,267 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ajaxlogin = Class.create();
2
+ ajaxlogin.prototype = {
3
+ initialize: function(formId){
4
+
5
+ /* Custom position values */
6
+ this.horizontalCorrection = parseInt(ajaxloginForm.horizontalCorrection);
7
+ this.verticalCorrection = parseInt(ajaxloginForm.verticalCorrection);
8
+
9
+ this.form = $(formId);
10
+ this.formId = formId;
11
+ if (!this.form) {
12
+ return;
13
+ }
14
+
15
+ this.bindElements();
16
+ this.prepareTopLinks();
17
+
18
+ },
19
+
20
+ bindElements:function (){
21
+ var elements = Form.getElements(this.form);
22
+ for (var row in elements) {
23
+ if (elements[row].id) {
24
+ this.writeDefaults(elements[row]);
25
+
26
+ Event.observe(elements[row],'focus',
27
+ function() {
28
+ if(this.value == ajaxlogin.loginValue || this.value == ajaxlogin.passwordValue) {
29
+ this.value = '';
30
+ }
31
+ }
32
+ );
33
+ Event.observe(elements[row],'blur',function() {
34
+ if(this.value.blank() && this.id == 'do-mini-login') {
35
+ this.value = ajaxlogin.loginValue;
36
+ }
37
+ else if(this.value.blank() && this.id == 'do-mini-password') {
38
+ this.value = ajaxlogin.passwordValue;
39
+ }
40
+ });
41
+ }
42
+ }
43
+ },
44
+
45
+
46
+ writeDefaults: function(elem) {
47
+ if(elem.id && elem.id == 'do-mini-login') {
48
+ ajaxlogin.loginValue = elem.value;
49
+ }
50
+
51
+ if(elem.id && elem.id == 'do-mini-password') {
52
+ ajaxlogin.passwordValue = elem.value;
53
+ }
54
+ },
55
+
56
+ computeBlockPosition: function(id) {
57
+
58
+ var a = $(ajaxlogin.loginLink);
59
+ var offsets = a.viewportOffset();
60
+ var dimensions = a.getDimensions();
61
+ var formDimensions = $(id).getDimensions();
62
+ var scrollOffsets = document.viewport.getScrollOffsets();
63
+
64
+ topOffset = parseInt(offsets[1]) + parseInt(dimensions.height) + parseInt(this.verticalCorrection) + parseInt(scrollOffsets.top);
65
+ leftOffset = parseInt(offsets[0]) - parseInt(formDimensions.width) + parseInt(dimensions.width) + parseInt(this.horizontalCorrection) + parseInt(scrollOffsets.left);
66
+
67
+
68
+ if(ajaxloginForm.computePosition) {
69
+ $(id).setStyle({
70
+ position:'absolute',
71
+ zIndex: 100,
72
+ top:topOffset+'px',
73
+ left:leftOffset+'px'
74
+
75
+ });
76
+ }
77
+
78
+ if(ajaxloginForm.hideForm) {
79
+ a.href = "javascript:void(0)";
80
+ }
81
+
82
+ Event.observe(a,'click',function() {
83
+ Effect.toggle(id+'_ul');
84
+ Effect.toggle(id, 'appear', {
85
+ afterFinish: function() {
86
+ ajaxloginForm.getClass().reset()
87
+ }
88
+ });
89
+ }.bind(this));
90
+
91
+
92
+ },
93
+
94
+
95
+ prepareTopLinks: function() {
96
+
97
+ $$("UL.links LI A").each(function(a) {
98
+
99
+ if(a.href.search(/customer\/account\/login\//ig) != -1) {
100
+ ajaxlogin.loginLink = a.id = 'ajax_login_link';
101
+ a.up('li').addClassName('ajaxlogin-logout-container');
102
+ }
103
+ if(a.href.search(/\/wishlist\//ig) != -1) {
104
+ a.addClassName('ajaxlogin-wishlist-container');
105
+ }
106
+ if(a.href.search(/\/checkout\/cart/ig) != -1) {
107
+ a.addClassName('ajaxlogin-toplink_cart');
108
+ }
109
+ if(a.href.search(/customer\/account\/create\//ig) != -1) {
110
+ ajaxlogin.registerLink = a.id = 'ajax_login_register';
111
+ a.up('li').addClassName('ajaxlogin-register-container');
112
+ }
113
+
114
+ });
115
+
116
+ },
117
+
118
+ reset: function() {
119
+
120
+ $$('#' + this.formId + ' .validation-advice').invoke('setStyle',{
121
+ display:'none'
122
+ });
123
+ this.form.reset();
124
+
125
+ },
126
+
127
+ validateForm: function() {
128
+ dataForm = new Validation(this.formId);
129
+ if(dataForm && dataForm.validate()) {
130
+ if(this.checkAjaxStatus()) {
131
+ this.prepareParams();
132
+ this.sendRequest();
133
+ }
134
+ else {
135
+ return true;
136
+ }
137
+ }
138
+ return false;
139
+ },
140
+
141
+ prepareParams: function() {
142
+
143
+ this.preCheckUrl = this.form.action.replace(/customer/igm,'fastlogin');
144
+ this.userEmail = this.form.getInputs('text','login[username]')[0].value;
145
+ this.userPassword = this.form.getInputs('password','login[password]')[0].value;
146
+
147
+ },
148
+
149
+ sendRequest: function() {
150
+
151
+ this.toggleLoader(1);
152
+
153
+ new Ajax.Request(this.preCheckUrl, {
154
+
155
+ method: 'post',
156
+ parameters: 'userEmail='+this.userEmail+"&userPassword="+this.userPassword,
157
+
158
+ onSuccess: function(avObj) {
159
+
160
+ if(avObj.responseText.isJSON() == false) {
161
+ ajaxloginForm.getClass().toggleLoader(2);
162
+ $('do-err-messages').innerHTML = avObj.responseText;
163
+ $$('#ajax_login_wrapper .messages').invoke('setStyle',{
164
+ display:'block'
165
+ });
166
+ return;
167
+ }
168
+
169
+ jsonObj = avObj.responseText.evalJSON();
170
+
171
+
172
+ if(jsonObj.action == 'redirect') {
173
+
174
+ obj = ajaxloginForm.getClass();
175
+
176
+ try {
177
+ obj.setTopLinkHtml('ajaxlogin-wishlist-container',jsonObj.wishlistLink);
178
+ } catch(err) {}
179
+
180
+ try {
181
+ obj.setTopLinkHtml('top-link-cart',jsonObj.cartLink);
182
+ } catch(err) {}
183
+
184
+ try {
185
+ obj.setTopLinkHtml('ajaxlogin-logout-container',jsonObj.logoutLink);
186
+ } catch(err) {}
187
+
188
+ try {
189
+ $$('.ajaxlogin-register-container').each(function(reg) {
190
+ $(reg).remove();
191
+ });
192
+ } catch(e) {}
193
+
194
+ $('ajax_login_wrapper').remove();
195
+
196
+ if(ajaxloginForm.cartSidebar) {
197
+ try {
198
+ obj.setTopLinkHtml('block-cart',jsonObj.sideBar);
199
+ truncateOptions();
200
+ } catch(err) {}
201
+ }
202
+ try {
203
+ $$(".welcome-msg")[0].innerHTML = jsonObj.welcome;
204
+ } catch(err) {}
205
+
206
+ }
207
+ }
208
+
209
+ });
210
+
211
+
212
+ },
213
+
214
+ toggleLoader: function(mode) {
215
+ if(mode == '1') {
216
+ $('ajax_login_contents').hide();
217
+ $('ajaxlogin_loader_holder').show();
218
+ }
219
+
220
+ else {
221
+ $('ajax_login_contents').show();
222
+ $('ajaxlogin_loader_holder').hide();
223
+ }
224
+ },
225
+
226
+ checkAjaxStatus: function() {
227
+ return ajaxloginForm.ajax;
228
+ },
229
+
230
+ setTopLinkHtml: function(class_name,data) {
231
+
232
+ data = data.replace(/\/uenc\/.+?\//ig,'/');
233
+
234
+ document.getElementsByClassName(class_name)[0].innerHTML = data;
235
+
236
+ if(class_name == 'block-cart') {
237
+ document.getElementsByClassName(class_name)[0].className = '';
238
+ }
239
+
240
+ }
241
+
242
+
243
+ }
244
+
245
+ var ajaxloginForm = {
246
+
247
+ init: function(id) {
248
+ this.form = new ajaxlogin(id);
249
+ },
250
+
251
+ getClass: function() {
252
+ return this.form;
253
+ },
254
+
255
+ ajax: true,
256
+ cartSidebar: true,
257
+ voidLogin: true,
258
+ hideForm: true,
259
+ computePosition: true,
260
+ horizontalCorrection: 0,
261
+ verticalCorrection: 0
262
+
263
+ };
264
+
265
+
266
+
267
+
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>magalter-fastlogin</name>
4
+ <version>1.0.0.2</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://www.magalter.com/license">Custom License</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Fast Login extension decorates standard Magento &#x201C;log in&#x201D; link and after user has clicked such link shows cozy log in form right below it.</summary>
10
+ <description>This application is great choice for those who value convenience of their customers. By default, fast login extension decorates standard Magento &#x201C;log in&#x201D; link and after user has clicked such link shows cozy log in form right below it. If the application is in &#x2018;Ajax&#x2019; mode, log in process is very fast. And after it, header links and cart sidebar are updated automatically without the need of current page being reloaded. And of course header is not the only place where log in form can be displayed. Site administrator can disable this functionality and place this block on any page manually just adding one line of code in any template file.</description>
11
+ <notes>1.0.0.2</notes>
12
+ <authors><author><name>Magalter</name><user>magalter</user><email>admin@magalter.com</email></author></authors>
13
+ <date>2012-01-05</date>
14
+ <time>21:29:59</time>
15
+ <contents><target name="magelocal"><dir name="Magalter"><dir name="Fastlogin"><dir name="Block"><file name="Login.php" hash="72ac56b0a1d735160460ef3cfc5c333e"/><file name="LogoutLink.php" hash="3dc7453ca1310637f9ce2f6dc0a893ab"/></dir><dir name="Helper"><file name="Data.php" hash="3e0fa20456492b0458dd83dced477bab"/></dir><dir name="controllers"><file name="AccountController.php" hash="a416722a293e564bfe873185516f5fd8"/></dir><dir name="etc"><file name="adminhtml.xml" hash="f09aeb8f5293e2dd4e5976451675e0a9"/><file name="config.xml" hash="d6f40c4af5f30cc70acc273991108090"/><file name="system.xml" hash="de27525c99fb71aef4398d295957eaed"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Magalter_Fastlogin.xml" hash="2d684ab6cb61e9b93e50e93cf23ec447"/></dir></target><target name="mageskin"><dir name="frontend"><dir name="default"><dir name="default"><dir name="magalter_fastlogin"><file name="styles.css" hash="647a56da29d64387d50bf2bead680018"/></dir><dir name="images"><file name="ajaxlogin_loader.gif" hash="e805ea7eca1f34c75ba0f93780d32d38"/><file name="ajaxlog_loader.gif" hash="f265b2e88148577ef3f38bd00712ae66"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="default"><dir name="default"><dir name="template"><dir name="magalter_fastlogin"><file name="headerlogin.phtml" hash="db967628748f454d1aa507702d0f6068"/><file name="logoutlink.phtml" hash="81fc47319aa90325b1acbff2506706db"/></dir></dir><dir name="layout"><file name="magalter_fastlogin.xml" hash="388b365acac1ef81046e880224e6d542"/></dir></dir></dir></dir></target><target name="magelocale"><dir name="en_US"><file name="Magalter_Fastlogin.csv" hash="92628d50e2c247eb02f42db477730506"/></dir></target><target name="mage"><dir name="js"><dir name="magalter_fastlogin"><file name="form.js" hash="89ad5c3dc28edb6433f16ff6f495c1e5"/></dir></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
18
+ </package>
skin/frontend/default/default/images/ajaxlog_loader.gif ADDED
Binary file
skin/frontend/default/default/images/ajaxlogin_loader.gif ADDED
Binary file
skin/frontend/default/default/magalter_fastlogin/styles.css ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ DIV#ajax_login_wrapper DIV#actions BUTTON{
3
+ float:right;
4
+ }
5
+
6
+ DIV#ajax_login_wrapper UL.messages {
7
+ display:none;
8
+ min-height:20px;
9
+ height:auto!important;
10
+ }
11
+
12
+ .fastloginButton {width:65px!important; background: none!important;}
13
+
14
+
15
+ DIV#ajax_login_wrapper {
16
+ background:yellow url("../images/bkg_header.jpg");
17
+ width:370px;
18
+ }
19
+
20
+ DIV#ajax_login_contents {
21
+ width:350px;
22
+ float:right;
23
+ min-height:20px;
24
+ height:auto!important;
25
+ position:relative;
26
+ z-index:1;
27
+ margin:0;
28
+ padding: 10px 7px;
29
+
30
+ }
31
+
32
+ DIV#ajaxlogin_loader_holder{
33
+ width:350px;
34
+ float:right;
35
+ min-height:20px;
36
+ height:auto!important;
37
+ position:relative;
38
+ z-index:1;
39
+ margin:0;
40
+ padding: 10px;
41
+ background:url("../images/ajaxlog_loader.gif") no-repeat center center;
42
+
43
+ }
44
+
45
+ DIV#ajax_login_contents INPUT {
46
+ width:120px;
47
+ }
48
+
49
+
50
+ DIV#ajax_login_contents DIV DIV {
51
+ background:none!important;
52
+ padding-left:0!important;
53
+ padding-right:10px!important;
54
+ text-align:left!important;
55
+ margin:0;
56
+ }
57
+
58
+ DIV#float1, DIV#float2{
59
+
60
+ position:relative;
61
+ width:140px;
62
+ float:left;
63
+ margin:0;
64
+ text-align:left;
65
+ }
66
+
67
+
68
+ IMG#ajaxlogin_loader_cache {display:block;position:absolute;left:-9999px;}