Version Notes
This extension can put a website on maintenance mode, whitelist IPs, and block dev and staging websites from general visitors.
Download this release
Release Info
Developer | SheroDesigns |
Extension | Shero_Maintenance |
Version | 1.0.0 |
Comparing to | |
See all releases |
Version 1.0.0
- app/code/local/Shero/Maintenance/Helper/Data.php +117 -0
- app/code/local/Shero/Maintenance/Model/Observer.php +44 -0
- app/code/local/Shero/Maintenance/controllers/IndexController.php +20 -0
- app/code/local/Shero/Maintenance/etc/config.xml +93 -0
- app/code/local/Shero/Maintenance/etc/system.xml +146 -0
- app/design/adminhtml/default/default/layout/picker.xml +8 -0
- app/design/frontend/base/default/layout/shero/maintenance.xml +18 -0
- app/design/frontend/base/default/template/maintenance/page/html/notices.phtml +51 -0
- app/etc/modules/Shero_Maintenance.xml +9 -0
- js/jscolor/arrow.gif +0 -0
- js/jscolor/cross.gif +0 -0
- js/jscolor/demo.html +12 -0
- js/jscolor/hs.png +0 -0
- js/jscolor/hv.png +0 -0
- js/jscolor/jscolor.js +840 -0
- js/shero/maintenance/maintenance.js +30 -0
- package.xml +27 -0
- skin/adminhtml/default/default/images/shero/shero-extension-banner_thumb.png +0 -0
- skin/frontend/base/default/css/shero/maintenance.css +6 -0
app/code/local/Shero/Maintenance/Helper/Data.php
ADDED
@@ -0,0 +1,117 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Shero_Maintenance_Helper_Data extends Mage_Core_Helper_Abstract
|
3 |
+
{
|
4 |
+
public function isEnabeled ()
|
5 |
+
{
|
6 |
+
$enabel = Mage::getStoreConfig('shero/maintenance_settings/maintenance_enable');
|
7 |
+
return $enabel == 1 ? true : false;
|
8 |
+
}
|
9 |
+
|
10 |
+
public function getAllowIpsArray()
|
11 |
+
{
|
12 |
+
$ipArray = array();
|
13 |
+
$string = Mage::getStoreConfig('shero/maintenance_settings/allow_ips');
|
14 |
+
if (isset($string)) {
|
15 |
+
$ipArray = explode(',', $string);
|
16 |
+
}
|
17 |
+
return $ipArray;
|
18 |
+
}
|
19 |
+
|
20 |
+
public function getRedirectUrl()
|
21 |
+
{
|
22 |
+
$string = Mage::getStoreConfig('shero/maintenance_settings/redirect_to');
|
23 |
+
if(!isset($string))
|
24 |
+
{
|
25 |
+
return false;
|
26 |
+
}
|
27 |
+
return $string;
|
28 |
+
}
|
29 |
+
|
30 |
+
public function setupPageEnabled()
|
31 |
+
{
|
32 |
+
$enabel = Mage::getStoreConfig('shero/maintenance_settings/setup_maintenance_enable');
|
33 |
+
return $enabel == 1 ? true : false;
|
34 |
+
}
|
35 |
+
|
36 |
+
public function getRedirectImage()
|
37 |
+
{
|
38 |
+
$image = Mage::getStoreConfig('shero/maintenance_settings/redirect_image');
|
39 |
+
$maxWidth = 750;
|
40 |
+
$maxHeight = 750;
|
41 |
+
if(!isset($image))
|
42 |
+
{
|
43 |
+
return false;
|
44 |
+
}
|
45 |
+
$basePath = Mage::getBaseDir(Mage_Core_Model_Store::URL_TYPE_MEDIA) . DS . "maintenance" .DS . $image;
|
46 |
+
$newPath = Mage::getBaseDir(Mage_Core_Model_Store::URL_TYPE_MEDIA) . DS . "maintenance" . DS . "resized" . DS . $image;
|
47 |
+
|
48 |
+
$imageObj = new Varien_Image($basePath);
|
49 |
+
$imageObj->constrainOnly(TRUE);
|
50 |
+
$imageObj->keepAspectRatio(FALSE);
|
51 |
+
$imageObj->keepFrame(FALSE);
|
52 |
+
$origwidth = $imageObj->getOriginalWidth();
|
53 |
+
$origheight = $imageObj->getOriginalHeight();
|
54 |
+
|
55 |
+
if($origwidth <= 400 && $origheight <= 400){
|
56 |
+
return Mage::getBaseUrl('media') . "maintenance/" . $image;
|
57 |
+
}
|
58 |
+
else if (!file_exists($newPath) && ($origheight > 400 || $origwidth > 400)) {
|
59 |
+
|
60 |
+
$scale = $origwidth/$origheight;
|
61 |
+
if(($maxWidth/$maxHeight) > $scale){
|
62 |
+
$maxWidth = $maxHeight * $scale;
|
63 |
+
}else
|
64 |
+
{
|
65 |
+
$maxHeight = $maxWidth / $scale;
|
66 |
+
}
|
67 |
+
$imageObj->resize($maxWidth, $maxHeight);
|
68 |
+
$imageObj->save($newPath);
|
69 |
+
unlink($basePath);
|
70 |
+
return Mage::getBaseUrl('media') . "maintenance/resized/" . $image;
|
71 |
+
}
|
72 |
+
else{
|
73 |
+
return Mage::getBaseUrl('media') . "maintenance/resized/" . $image;
|
74 |
+
}
|
75 |
+
}
|
76 |
+
|
77 |
+
public function maintenanceMessage()
|
78 |
+
{
|
79 |
+
$string = Mage::getStoreConfig('shero/maintenance_settings/maintenance_message');
|
80 |
+
if(!isset($string))
|
81 |
+
{
|
82 |
+
return false;
|
83 |
+
}
|
84 |
+
return $string;
|
85 |
+
}
|
86 |
+
|
87 |
+
|
88 |
+
//alert settings
|
89 |
+
public function isAlertEnabled()
|
90 |
+
{
|
91 |
+
$enabled = Mage::getStoreConfig('shero/maintenance_alert/alert_enabled');
|
92 |
+
return $enabled == 1 ? true : false;
|
93 |
+
}
|
94 |
+
|
95 |
+
public function getAlertMessage()
|
96 |
+
{
|
97 |
+
$string = Mage::getStoreConfig('shero/maintenance_alert/alert_message');
|
98 |
+
if(!isset($string))
|
99 |
+
{
|
100 |
+
return false;
|
101 |
+
}
|
102 |
+
return $string;
|
103 |
+
}
|
104 |
+
|
105 |
+
public function getBackgroundColor()
|
106 |
+
{
|
107 |
+
$color = Mage::getStoreConfig('shero/maintenance_alert/alert_color');
|
108 |
+
return $color;
|
109 |
+
}
|
110 |
+
|
111 |
+
public function getTextColor()
|
112 |
+
{
|
113 |
+
$color = Mage::getStoreConfig('shero/maintenance_alert/alert_text_color');
|
114 |
+
return $color;
|
115 |
+
}
|
116 |
+
|
117 |
+
}
|
app/code/local/Shero/Maintenance/Model/Observer.php
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Shero_Maintenance_Model_Observer extends Varien_Event_Observer
|
3 |
+
{
|
4 |
+
public function switchStoreToMaintenance()
|
5 |
+
{
|
6 |
+
$myIp = $_SERVER['REMOTE_ADDR'];
|
7 |
+
|
8 |
+
$maintenanceOff = MAGENTO_ROOT . '/maintenance.off';
|
9 |
+
|
10 |
+
$isEnable = Mage::helper('shero_maintenance')->isEnabeled();
|
11 |
+
$allowedIps = Mage::helper('shero_maintenance')->getAllowIpsArray();
|
12 |
+
$redirectUrl = Mage::helper('shero_maintenance')->getRedirectUrl();
|
13 |
+
$isSetupPageEnabled = Mage::helper('shero_maintenance')->setupPageEnabled();
|
14 |
+
$redirectImage = Mage::helper('shero_maintenance')->getRedirectImage();
|
15 |
+
$maintenanceMessage = Mage::helper('shero_maintenance')->maintenanceMessage();
|
16 |
+
|
17 |
+
if ($isEnable === true && !in_array($myIp, $allowedIps) && !file_exists($maintenanceOff)) {
|
18 |
+
|
19 |
+
if($isSetupPageEnabled === true && ($redirectImage!=false || $maintenanceMessage!=false)){
|
20 |
+
echo '<div style="margin: auto; width: 800px;">
|
21 |
+
<div><img style="display: block; margin-left: auto; margin-right: auto" src='.$redirectImage.'></div>
|
22 |
+
<div style="font-size: 20px; display: block; margin-left: 165px; margin-right: auto;" >'.$maintenanceMessage.'</div>
|
23 |
+
</div>';
|
24 |
+
exit;
|
25 |
+
}
|
26 |
+
else
|
27 |
+
{
|
28 |
+
if($redirectUrl != false )
|
29 |
+
{
|
30 |
+
header("location: $redirectUrl");
|
31 |
+
exit;
|
32 |
+
}
|
33 |
+
else
|
34 |
+
{
|
35 |
+
echo '<div style="margin: auto; width: 800px; padding-top: 20px;">
|
36 |
+
<div style="margin: auto; width: 800px; font-size: 15px" ><h3>Our website is down for required maintenance right now, but you should be able to get back on shortly.</h3></div>
|
37 |
+
<div style="font-size: 18px; display: block; margin-left: 165px; margin-right: auto;">Thanks for your patience as we improve the website.</div>
|
38 |
+
</div>';
|
39 |
+
exit;
|
40 |
+
}
|
41 |
+
}
|
42 |
+
}
|
43 |
+
}
|
44 |
+
}
|
app/code/local/Shero/Maintenance/controllers/IndexController.php
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Shero_Maintenance_IndexController extends Mage_Core_Controller_Front_Action
|
3 |
+
{
|
4 |
+
public function indexAction()
|
5 |
+
{
|
6 |
+
$alertEnabled = Mage::helper('shero_maintenance')->isAlertEnabled();
|
7 |
+
$alertMessage = Mage::helper('shero_maintenance')->getAlertMessage();
|
8 |
+
$alertBackgroundColor = Mage::helper('shero_maintenance')->getBackgroundColor();
|
9 |
+
$alertTextColor = Mage::helper('shero_maintenance')->getTextColor();
|
10 |
+
|
11 |
+
$send = $alertMessage.",".$alertBackgroundColor.",".$alertTextColor;
|
12 |
+
|
13 |
+
if($alertEnabled == true && $alertMessage != false){
|
14 |
+
$this->getResponse()->setBody($send);
|
15 |
+
}
|
16 |
+
else{
|
17 |
+
echo "inactive";
|
18 |
+
}
|
19 |
+
}
|
20 |
+
}
|
app/code/local/Shero/Maintenance/etc/config.xml
ADDED
@@ -0,0 +1,93 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Shero_Maintenance>
|
5 |
+
<version>1.0.0</version>
|
6 |
+
</Shero_Maintenance>
|
7 |
+
</modules>
|
8 |
+
|
9 |
+
<global>
|
10 |
+
<helpers>
|
11 |
+
<shero_maintenance>
|
12 |
+
<class>Shero_Maintenance_Helper</class>
|
13 |
+
</shero_maintenance>
|
14 |
+
</helpers>
|
15 |
+
|
16 |
+
<models>
|
17 |
+
<shero_maintenance>
|
18 |
+
<class>Shero_Maintenance_Model</class>
|
19 |
+
</shero_maintenance>
|
20 |
+
</models>
|
21 |
+
</global>
|
22 |
+
|
23 |
+
<frontend>
|
24 |
+
<events>
|
25 |
+
<controller_action_postdispatch>
|
26 |
+
<observers>
|
27 |
+
<shero_maintenance>
|
28 |
+
<type>singleton</type>
|
29 |
+
<class>Shero_Maintenance_Model_Observer</class>
|
30 |
+
<method>switchStoreToMaintenance</method>
|
31 |
+
</shero_maintenance>
|
32 |
+
</observers>
|
33 |
+
</controller_action_postdispatch>
|
34 |
+
</events>
|
35 |
+
|
36 |
+
<layout>
|
37 |
+
<updates>
|
38 |
+
<shero_maintenance>
|
39 |
+
<file>shero/maintenance.xml</file>
|
40 |
+
</shero_maintenance>
|
41 |
+
</updates>
|
42 |
+
</layout>
|
43 |
+
|
44 |
+
<routers>
|
45 |
+
<shero_maintenance>
|
46 |
+
<use>standard</use>
|
47 |
+
<args>
|
48 |
+
<module>Shero_Maintenance</module>
|
49 |
+
<frontName>alert</frontName>
|
50 |
+
</args>
|
51 |
+
</shero_maintenance>
|
52 |
+
</routers>
|
53 |
+
</frontend>
|
54 |
+
|
55 |
+
<adminhtml>
|
56 |
+
<layout>
|
57 |
+
<updates>
|
58 |
+
<shero_maintenance>
|
59 |
+
<file>picker.xml</file>
|
60 |
+
</shero_maintenance>
|
61 |
+
</updates>
|
62 |
+
</layout>
|
63 |
+
<acl>
|
64 |
+
<resources>
|
65 |
+
<admin>
|
66 |
+
<children>
|
67 |
+
<system>
|
68 |
+
<children>
|
69 |
+
<config>
|
70 |
+
<children>
|
71 |
+
<shero>
|
72 |
+
<title>Shero Extensions</title>
|
73 |
+
</shero>
|
74 |
+
</children>
|
75 |
+
</config>
|
76 |
+
</children>
|
77 |
+
</system>
|
78 |
+
</children>
|
79 |
+
</admin>
|
80 |
+
</resources>
|
81 |
+
</acl>
|
82 |
+
</adminhtml>
|
83 |
+
<default>
|
84 |
+
<shero>
|
85 |
+
<maintenance_settings>
|
86 |
+
<maintenance_enable>0</maintenance_enable>
|
87 |
+
</maintenance_settings>
|
88 |
+
<maintenance_alert>
|
89 |
+
<alert_enabled>0</alert_enabled>
|
90 |
+
</maintenance_alert>
|
91 |
+
</shero>
|
92 |
+
</default>
|
93 |
+
</config>
|
app/code/local/Shero/Maintenance/etc/system.xml
ADDED
@@ -0,0 +1,146 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<tabs>
|
4 |
+
<shero translate="label" module="shero_maintenance">
|
5 |
+
<label><![CDATA[<div style="position: absolute;"><img id="sherologo" src="" alt="" border="0" /></div> <script>
|
6 |
+
var n = SKIN_URL.indexOf("adminhtml");
|
7 |
+
$('sherologo').src = SKIN_URL.substring(0, n) + "adminhtml/default/default/images/shero/shero-extension-banner_thumb.png";</script>]]></label>
|
8 |
+
<sort_order>900</sort_order>
|
9 |
+
</shero>
|
10 |
+
</tabs>
|
11 |
+
<sections>
|
12 |
+
<shero translate="label" module="shero_maintenance">
|
13 |
+
<label><![CDATA[Maintenance Mode & IP Whitelist]]></label>
|
14 |
+
<tab>shero</tab>
|
15 |
+
<frontend_type>text</frontend_type>
|
16 |
+
<sort_order>999</sort_order>
|
17 |
+
<show_in_default>1</show_in_default>
|
18 |
+
<show_in_website>1</show_in_website>
|
19 |
+
<show_in_store>1</show_in_store>
|
20 |
+
<groups>
|
21 |
+
<maintenance_settings translate="label">
|
22 |
+
<label>Maintenance Settings</label>
|
23 |
+
<frontend_type>text</frontend_type>
|
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 |
+
<fields>
|
29 |
+
<maintenance_enable translate="label">
|
30 |
+
<label>Enabled</label>
|
31 |
+
<frontend_type>select</frontend_type>
|
32 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
33 |
+
<sort_order>1</sort_order>
|
34 |
+
<show_in_default>1</show_in_default>
|
35 |
+
<show_in_website>1</show_in_website>
|
36 |
+
<show_in_store>1</show_in_store>
|
37 |
+
</maintenance_enable>
|
38 |
+
<allow_ips translate="label,comment">
|
39 |
+
<label>Allow IPs</label>
|
40 |
+
<comment><![CDATA[add allow IPs comma separated values. ex: 127.0.0.1,10.10.10.10]]></comment>
|
41 |
+
<frontend_type>textarea</frontend_type>
|
42 |
+
<sort_order>2</sort_order>
|
43 |
+
<show_in_default>1</show_in_default>
|
44 |
+
<show_in_website>1</show_in_website>
|
45 |
+
<show_in_store>1</show_in_store>
|
46 |
+
<depends><maintenance_enable>1</maintenance_enable></depends>
|
47 |
+
</allow_ips>
|
48 |
+
<redirect_to translate="label,comment">
|
49 |
+
<label>Redirect to</label>
|
50 |
+
<comment><![CDATA[add an URL or file name.ex:http://www.example.com or example.html. If blank the page will redirect to our default maintenance page]]></comment>
|
51 |
+
<frontend_type>text</frontend_type>
|
52 |
+
<sort_order>3</sort_order>
|
53 |
+
<show_in_default>1</show_in_default>
|
54 |
+
<show_in_website>1</show_in_website>
|
55 |
+
<show_in_store>1</show_in_store>
|
56 |
+
<depends><maintenance_enable>1</maintenance_enable></depends>
|
57 |
+
<depends><setup_maintenance_enable>0</setup_maintenance_enable></depends>
|
58 |
+
</redirect_to>
|
59 |
+
<setup_maintenance_enable translate="label">
|
60 |
+
<label>Setup Your Own Page</label>
|
61 |
+
<frontend_type>select</frontend_type>
|
62 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
63 |
+
<sort_order>4</sort_order>
|
64 |
+
<show_in_default>1</show_in_default>
|
65 |
+
<show_in_website>1</show_in_website>
|
66 |
+
<show_in_store>1</show_in_store>
|
67 |
+
<depends><maintenance_enable>1</maintenance_enable></depends>
|
68 |
+
</setup_maintenance_enable>
|
69 |
+
<redirect_image translate="label comment">
|
70 |
+
<label>Maintenance Page Logo</label>
|
71 |
+
<comment>Allowed file types: jpeg, gif, png.</comment>
|
72 |
+
<frontend_type>image</frontend_type>
|
73 |
+
<backend_model>adminhtml/system_config_backend_image</backend_model>
|
74 |
+
<upload_dir config="system/filesystem/media" scope_info="1">maintenance</upload_dir>
|
75 |
+
<base_url type="media" scope_info="1">maintenance</base_url>
|
76 |
+
<sort_order>5</sort_order>
|
77 |
+
<show_in_default>1</show_in_default>
|
78 |
+
<show_in_website>1</show_in_website>
|
79 |
+
<show_in_store>1</show_in_store>
|
80 |
+
<depends><maintenance_enable>1</maintenance_enable><setup_maintenance_enable>1</setup_maintenance_enable></depends>
|
81 |
+
</redirect_image>
|
82 |
+
<maintenance_message translate="label">
|
83 |
+
<label>Maintenance Message</label>
|
84 |
+
<frontend_type>textarea</frontend_type>
|
85 |
+
<sort_order>6</sort_order>
|
86 |
+
<show_in_default>1</show_in_default>
|
87 |
+
<show_in_website>1</show_in_website>
|
88 |
+
<show_in_store>1</show_in_store>
|
89 |
+
<depends><maintenance_enable>1</maintenance_enable><setup_maintenance_enable>1</setup_maintenance_enable></depends>
|
90 |
+
</maintenance_message>
|
91 |
+
</fields>
|
92 |
+
</maintenance_settings>
|
93 |
+
<maintenance_alert translate="label">
|
94 |
+
<label>Maintenance Alert</label>
|
95 |
+
<frontend_type>text</frontend_type>
|
96 |
+
<sort_order>2</sort_order>
|
97 |
+
<show_in_default>1</show_in_default>
|
98 |
+
<show_in_website>1</show_in_website>
|
99 |
+
<show_in_store>1</show_in_store>
|
100 |
+
<fields>
|
101 |
+
<alert_enabled translate="label">
|
102 |
+
<label>Enable Maintenance Alert</label>
|
103 |
+
<frontend_type>select</frontend_type>
|
104 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
105 |
+
<sort_order>1</sort_order>
|
106 |
+
<show_in_default>1</show_in_default>
|
107 |
+
<show_in_website>1</show_in_website>
|
108 |
+
<show_in_store>1</show_in_store>
|
109 |
+
</alert_enabled>
|
110 |
+
<alert_message translate="label">
|
111 |
+
<label>Alert Message</label>
|
112 |
+
<frontend_type>text</frontend_type>
|
113 |
+
<sort_order>2</sort_order>
|
114 |
+
<show_in_default>1</show_in_default>
|
115 |
+
<show_in_website>1</show_in_website>
|
116 |
+
<show_in_store>1</show_in_store>
|
117 |
+
<depends><alert_enabled>1</alert_enabled></depends>
|
118 |
+
</alert_message>
|
119 |
+
<alert_color>
|
120 |
+
<label>Alert Background Color</label>
|
121 |
+
<frontend_type>text</frontend_type>
|
122 |
+
<validate>color</validate>
|
123 |
+
<sort_order>3</sort_order>
|
124 |
+
<show_in_default>1</show_in_default>
|
125 |
+
<show_in_website>1</show_in_website>
|
126 |
+
<show_in_store>1</show_in_store>
|
127 |
+
<comment>Specify the background color.</comment>
|
128 |
+
<depends><alert_enabled>1</alert_enabled></depends>
|
129 |
+
</alert_color>
|
130 |
+
<alert_text_color>
|
131 |
+
<label>Alert Text Color</label>
|
132 |
+
<frontend_type>text</frontend_type>
|
133 |
+
<validate>color</validate>
|
134 |
+
<sort_order>3</sort_order>
|
135 |
+
<show_in_default>1</show_in_default>
|
136 |
+
<show_in_website>1</show_in_website>
|
137 |
+
<show_in_store>1</show_in_store>
|
138 |
+
<comment>Specify the text color.</comment>
|
139 |
+
<depends><alert_enabled>1</alert_enabled></depends>
|
140 |
+
</alert_text_color>
|
141 |
+
</fields>
|
142 |
+
</maintenance_alert>
|
143 |
+
</groups>
|
144 |
+
</shero>
|
145 |
+
</sections>
|
146 |
+
</config>
|
app/design/adminhtml/default/default/layout/picker.xml
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<layout version="0.1.1">
|
3 |
+
<adminhtml_system_config_edit>
|
4 |
+
<reference name="head">
|
5 |
+
<action method="addJs"><file>jscolor/jscolor.js</file></action>
|
6 |
+
</reference>
|
7 |
+
</adminhtml_system_config_edit>
|
8 |
+
</layout>
|
app/design/frontend/base/default/layout/shero/maintenance.xml
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<layout>
|
2 |
+
<default>
|
3 |
+
<reference name="head">
|
4 |
+
<action method="addJs">
|
5 |
+
<script>shero/maintenance/maintenance.js</script>
|
6 |
+
</action>
|
7 |
+
<action method="addItem">
|
8 |
+
<type>skin_css</type>
|
9 |
+
<name>css/shero/maintenance.css</name>
|
10 |
+
</action>
|
11 |
+
</reference>
|
12 |
+
<reference name='global_notices'>
|
13 |
+
<action method='setTemplate'>
|
14 |
+
<template>maintenance/page/html/notices.phtml</template>
|
15 |
+
</action>
|
16 |
+
</reference>
|
17 |
+
</default>
|
18 |
+
</layout>
|
app/design/frontend/base/default/template/maintenance/page/html/notices.phtml
ADDED
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Academic Free License (AFL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE_AFL.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/afl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to license@magento.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* DISCLAIMER
|
16 |
+
*
|
17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
+
* versions in the future. If you wish to customize Magento for your
|
19 |
+
* needs please refer to http://www.magento.com for more information.
|
20 |
+
*
|
21 |
+
* @category design
|
22 |
+
* @package base_default
|
23 |
+
* @copyright Copyright (c) 2006-2016 X.commerce, Inc. and affiliates (http://www.magento.com)
|
24 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
25 |
+
*/
|
26 |
+
?>
|
27 |
+
<?php
|
28 |
+
/**
|
29 |
+
* @var $this Mage_Page_Block_Html_Notices
|
30 |
+
*/
|
31 |
+
?>
|
32 |
+
<?php if ($this->displayNoscriptNotice()): ?>
|
33 |
+
<noscript>
|
34 |
+
<div class="global-site-notice noscript">
|
35 |
+
<div class="notice-inner">
|
36 |
+
<p>
|
37 |
+
<strong><?php echo $this->__('JavaScript seems to be disabled in your browser.'); ?></strong><br />
|
38 |
+
<?php echo $this->__('You must have JavaScript enabled in your browser to utilize the functionality of this website.'); ?>
|
39 |
+
</p>
|
40 |
+
</div>
|
41 |
+
</div>
|
42 |
+
</noscript>
|
43 |
+
<?php endif; ?>
|
44 |
+
<span id="maintenance_alert_url" style="display: none;"><?php echo Mage::getUrl('alert');?></span>
|
45 |
+
<span id="alert"></span>
|
46 |
+
<?php if ($this->displayDemoNotice()): ?>
|
47 |
+
<div class="global-site-notice demo-notice">
|
48 |
+
<div class="notice-inner"><p><?php echo $this->__('This is a demo store. Any orders placed through this store will not be honored or fulfilled.') ?></p></div>
|
49 |
+
</div>
|
50 |
+
<?php endif; ?>
|
51 |
+
|
app/etc/modules/Shero_Maintenance.xml
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Shero_Maintenance>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>local</codePool>
|
7 |
+
</Shero_Maintenance>
|
8 |
+
</modules>
|
9 |
+
</config>
|
js/jscolor/arrow.gif
ADDED
Binary file
|
js/jscolor/cross.gif
ADDED
Binary file
|
js/jscolor/demo.html
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<html>
|
2 |
+
<head>
|
3 |
+
<title>jscolor demo</title>
|
4 |
+
</head>
|
5 |
+
<body>
|
6 |
+
|
7 |
+
<script type="text/javascript" src="jscolor.js"></script>
|
8 |
+
|
9 |
+
Click here: <input class="color" value="66ff00">
|
10 |
+
|
11 |
+
</body>
|
12 |
+
</html>
|
js/jscolor/hs.png
ADDED
Binary file
|
js/jscolor/hv.png
ADDED
Binary file
|
js/jscolor/jscolor.js
ADDED
@@ -0,0 +1,840 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* jscolor, JavaScript Color Picker
|
3 |
+
*
|
4 |
+
* @version 1.3.1
|
5 |
+
* @license GNU Lesser General Public License, http://www.gnu.org/copyleft/lesser.html
|
6 |
+
* @author Jan Odvarko, http://odvarko.cz
|
7 |
+
* @created 2008-06-15
|
8 |
+
* @updated 2010-01-23
|
9 |
+
* @link http://jscolor.com
|
10 |
+
*/
|
11 |
+
|
12 |
+
|
13 |
+
var jscolor = {
|
14 |
+
|
15 |
+
|
16 |
+
dir : '', // location of jscolor directory (leave empty to autodetect)
|
17 |
+
bindClass : 'color', // class name
|
18 |
+
binding : true, // automatic binding via <input class="...">
|
19 |
+
preloading : true, // use image preloading?
|
20 |
+
|
21 |
+
|
22 |
+
install : function() {
|
23 |
+
jscolor.addEvent(window, 'load', jscolor.init);
|
24 |
+
},
|
25 |
+
|
26 |
+
|
27 |
+
init : function() {
|
28 |
+
if(jscolor.binding) {
|
29 |
+
jscolor.bind();
|
30 |
+
}
|
31 |
+
if(jscolor.preloading) {
|
32 |
+
jscolor.preload();
|
33 |
+
}
|
34 |
+
},
|
35 |
+
|
36 |
+
|
37 |
+
getDir : function() {
|
38 |
+
if(!jscolor.dir) {
|
39 |
+
var detected = jscolor.detectDir();
|
40 |
+
jscolor.dir = detected!==false ? detected : 'jscolor/';
|
41 |
+
}
|
42 |
+
return jscolor.dir;
|
43 |
+
},
|
44 |
+
|
45 |
+
|
46 |
+
detectDir : function() {
|
47 |
+
var base = location.href;
|
48 |
+
|
49 |
+
var e = document.getElementsByTagName('base');
|
50 |
+
for(var i=0; i<e.length; i+=1) {
|
51 |
+
if(e[i].href) { base = e[i].href; }
|
52 |
+
}
|
53 |
+
|
54 |
+
var e = document.getElementsByTagName('script');
|
55 |
+
for(var i=0; i<e.length; i+=1) {
|
56 |
+
if(e[i].src && /(^|\/)jscolor\.js([?#].*)?$/i.test(e[i].src)) {
|
57 |
+
var src = new jscolor.URI(e[i].src);
|
58 |
+
var srcAbs = src.toAbsolute(base);
|
59 |
+
srcAbs.path = srcAbs.path.replace(/[^\/]+$/, ''); // remove filename
|
60 |
+
srcAbs.query = null;
|
61 |
+
srcAbs.fragment = null;
|
62 |
+
return srcAbs.toString();
|
63 |
+
}
|
64 |
+
}
|
65 |
+
return false;
|
66 |
+
},
|
67 |
+
|
68 |
+
|
69 |
+
bind : function() {
|
70 |
+
var matchClass = new RegExp('(^|\\s)('+jscolor.bindClass+')\\s*(\\{[^}]*\\})?', 'i');
|
71 |
+
var e = document.getElementsByTagName('input');
|
72 |
+
for(var i=0; i<e.length; i+=1) {
|
73 |
+
var m;
|
74 |
+
if(!e[i].color && e[i].className && (m = e[i].className.match(matchClass))) {
|
75 |
+
var prop = {};
|
76 |
+
if(m[3]) {
|
77 |
+
try {
|
78 |
+
eval('prop='+m[3]);
|
79 |
+
} catch(eInvalidProp) {}
|
80 |
+
}
|
81 |
+
e[i].color = new jscolor.color(e[i], prop);
|
82 |
+
}
|
83 |
+
}
|
84 |
+
},
|
85 |
+
|
86 |
+
|
87 |
+
preload : function() {
|
88 |
+
for(var fn in jscolor.imgRequire) {
|
89 |
+
if(jscolor.imgRequire.hasOwnProperty(fn)) {
|
90 |
+
jscolor.loadImage(fn);
|
91 |
+
}
|
92 |
+
}
|
93 |
+
},
|
94 |
+
|
95 |
+
|
96 |
+
images : {
|
97 |
+
pad : [ 181, 101 ],
|
98 |
+
sld : [ 16, 101 ],
|
99 |
+
cross : [ 15, 15 ],
|
100 |
+
arrow : [ 7, 11 ]
|
101 |
+
},
|
102 |
+
|
103 |
+
|
104 |
+
imgRequire : {},
|
105 |
+
imgLoaded : {},
|
106 |
+
|
107 |
+
|
108 |
+
requireImage : function(filename) {
|
109 |
+
jscolor.imgRequire[filename] = true;
|
110 |
+
},
|
111 |
+
|
112 |
+
|
113 |
+
loadImage : function(filename) {
|
114 |
+
if(!jscolor.imgLoaded[filename]) {
|
115 |
+
jscolor.imgLoaded[filename] = new Image();
|
116 |
+
jscolor.imgLoaded[filename].src = jscolor.getDir()+filename;
|
117 |
+
}
|
118 |
+
},
|
119 |
+
|
120 |
+
|
121 |
+
fetchElement : function(mixed) {
|
122 |
+
return typeof mixed === 'string' ? document.getElementById(mixed) : mixed;
|
123 |
+
},
|
124 |
+
|
125 |
+
|
126 |
+
addEvent : function(el, evnt, func) {
|
127 |
+
if(el.addEventListener) {
|
128 |
+
el.addEventListener(evnt, func, false);
|
129 |
+
} else if(el.attachEvent) {
|
130 |
+
el.attachEvent('on'+evnt, func);
|
131 |
+
}
|
132 |
+
},
|
133 |
+
|
134 |
+
|
135 |
+
fireEvent : function(el, evnt) {
|
136 |
+
if(!el) {
|
137 |
+
return;
|
138 |
+
}
|
139 |
+
if(document.createEventObject) {
|
140 |
+
var ev = document.createEventObject();
|
141 |
+
el.fireEvent('on'+evnt, ev);
|
142 |
+
} else if(document.createEvent) {
|
143 |
+
var ev = document.createEvent('HTMLEvents');
|
144 |
+
ev.initEvent(evnt, true, true);
|
145 |
+
el.dispatchEvent(ev);
|
146 |
+
} else if(el['on'+evnt]) { // alternatively use the traditional event model (IE5)
|
147 |
+
el['on'+evnt]();
|
148 |
+
}
|
149 |
+
},
|
150 |
+
|
151 |
+
|
152 |
+
getElementPos : function(e) {
|
153 |
+
var e1=e, e2=e;
|
154 |
+
var x=0, y=0;
|
155 |
+
if(e1.offsetParent) {
|
156 |
+
do {
|
157 |
+
x += e1.offsetLeft;
|
158 |
+
y += e1.offsetTop;
|
159 |
+
} while(e1 = e1.offsetParent);
|
160 |
+
}
|
161 |
+
while((e2 = e2.parentNode) && e2.nodeName.toUpperCase() !== 'BODY') {
|
162 |
+
x -= e2.scrollLeft;
|
163 |
+
y -= e2.scrollTop;
|
164 |
+
}
|
165 |
+
return [x, y];
|
166 |
+
},
|
167 |
+
|
168 |
+
|
169 |
+
getElementSize : function(e) {
|
170 |
+
return [e.offsetWidth, e.offsetHeight];
|
171 |
+
},
|
172 |
+
|
173 |
+
|
174 |
+
getMousePos : function(e) {
|
175 |
+
if(!e) { e = window.event; }
|
176 |
+
if(typeof e.pageX === 'number') {
|
177 |
+
return [e.pageX, e.pageY];
|
178 |
+
} else if(typeof e.clientX === 'number') {
|
179 |
+
return [
|
180 |
+
e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft,
|
181 |
+
e.clientY + document.body.scrollTop + document.documentElement.scrollTop
|
182 |
+
];
|
183 |
+
}
|
184 |
+
},
|
185 |
+
|
186 |
+
|
187 |
+
getViewPos : function() {
|
188 |
+
if(typeof window.pageYOffset === 'number') {
|
189 |
+
return [window.pageXOffset, window.pageYOffset];
|
190 |
+
} else if(document.body && (document.body.scrollLeft || document.body.scrollTop)) {
|
191 |
+
return [document.body.scrollLeft, document.body.scrollTop];
|
192 |
+
} else if(document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop)) {
|
193 |
+
return [document.documentElement.scrollLeft, document.documentElement.scrollTop];
|
194 |
+
} else {
|
195 |
+
return [0, 0];
|
196 |
+
}
|
197 |
+
},
|
198 |
+
|
199 |
+
|
200 |
+
getViewSize : function() {
|
201 |
+
if(typeof window.innerWidth === 'number') {
|
202 |
+
return [window.innerWidth, window.innerHeight];
|
203 |
+
} else if(document.body && (document.body.clientWidth || document.body.clientHeight)) {
|
204 |
+
return [document.body.clientWidth, document.body.clientHeight];
|
205 |
+
} else if(document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
|
206 |
+
return [document.documentElement.clientWidth, document.documentElement.clientHeight];
|
207 |
+
} else {
|
208 |
+
return [0, 0];
|
209 |
+
}
|
210 |
+
},
|
211 |
+
|
212 |
+
|
213 |
+
URI : function(uri) { // See RFC3986
|
214 |
+
|
215 |
+
this.scheme = null;
|
216 |
+
this.authority = null;
|
217 |
+
this.path = '';
|
218 |
+
this.query = null;
|
219 |
+
this.fragment = null;
|
220 |
+
|
221 |
+
this.parse = function(uri) {
|
222 |
+
var m = uri.match(/^(([A-Za-z][0-9A-Za-z+.-]*)(:))?((\/\/)([^\/?#]*))?([^?#]*)((\?)([^#]*))?((#)(.*))?/);
|
223 |
+
this.scheme = m[3] ? m[2] : null;
|
224 |
+
this.authority = m[5] ? m[6] : null;
|
225 |
+
this.path = m[7];
|
226 |
+
this.query = m[9] ? m[10] : null;
|
227 |
+
this.fragment = m[12] ? m[13] : null;
|
228 |
+
return this;
|
229 |
+
};
|
230 |
+
|
231 |
+
this.toString = function() {
|
232 |
+
var result = '';
|
233 |
+
if(this.scheme !== null) { result = result + this.scheme + ':'; }
|
234 |
+
if(this.authority !== null) { result = result + '//' + this.authority; }
|
235 |
+
if(this.path !== null) { result = result + this.path; }
|
236 |
+
if(this.query !== null) { result = result + '?' + this.query; }
|
237 |
+
if(this.fragment !== null) { result = result + '#' + this.fragment; }
|
238 |
+
return result;
|
239 |
+
};
|
240 |
+
|
241 |
+
this.toAbsolute = function(base) {
|
242 |
+
var base = new jscolor.URI(base);
|
243 |
+
var r = this;
|
244 |
+
var t = new jscolor.URI;
|
245 |
+
|
246 |
+
if(base.scheme === null) { return false; }
|
247 |
+
|
248 |
+
if(r.scheme !== null && r.scheme.toLowerCase() === base.scheme.toLowerCase()) {
|
249 |
+
r.scheme = null;
|
250 |
+
}
|
251 |
+
|
252 |
+
if(r.scheme !== null) {
|
253 |
+
t.scheme = r.scheme;
|
254 |
+
t.authority = r.authority;
|
255 |
+
t.path = removeDotSegments(r.path);
|
256 |
+
t.query = r.query;
|
257 |
+
} else {
|
258 |
+
if(r.authority !== null) {
|
259 |
+
t.authority = r.authority;
|
260 |
+
t.path = removeDotSegments(r.path);
|
261 |
+
t.query = r.query;
|
262 |
+
} else {
|
263 |
+
if(r.path === '') { // TODO: == or === ?
|
264 |
+
t.path = base.path;
|
265 |
+
if(r.query !== null) {
|
266 |
+
t.query = r.query;
|
267 |
+
} else {
|
268 |
+
t.query = base.query;
|
269 |
+
}
|
270 |
+
} else {
|
271 |
+
if(r.path.substr(0,1) === '/') {
|
272 |
+
t.path = removeDotSegments(r.path);
|
273 |
+
} else {
|
274 |
+
if(base.authority !== null && base.path === '') { // TODO: == or === ?
|
275 |
+
t.path = '/'+r.path;
|
276 |
+
} else {
|
277 |
+
t.path = base.path.replace(/[^\/]+$/,'')+r.path;
|
278 |
+
}
|
279 |
+
t.path = removeDotSegments(t.path);
|
280 |
+
}
|
281 |
+
t.query = r.query;
|
282 |
+
}
|
283 |
+
t.authority = base.authority;
|
284 |
+
}
|
285 |
+
t.scheme = base.scheme;
|
286 |
+
}
|
287 |
+
t.fragment = r.fragment;
|
288 |
+
|
289 |
+
return t;
|
290 |
+
};
|
291 |
+
|
292 |
+
function removeDotSegments(path) {
|
293 |
+
var out = '';
|
294 |
+
while(path) {
|
295 |
+
if(path.substr(0,3)==='../' || path.substr(0,2)==='./') {
|
296 |
+
path = path.replace(/^\.+/,'').substr(1);
|
297 |
+
} else if(path.substr(0,3)==='/./' || path==='/.') {
|
298 |
+
path = '/'+path.substr(3);
|
299 |
+
} else if(path.substr(0,4)==='/../' || path==='/..') {
|
300 |
+
path = '/'+path.substr(4);
|
301 |
+
out = out.replace(/\/?[^\/]*$/, '');
|
302 |
+
} else if(path==='.' || path==='..') {
|
303 |
+
path = '';
|
304 |
+
} else {
|
305 |
+
var rm = path.match(/^\/?[^\/]*/)[0];
|
306 |
+
path = path.substr(rm.length);
|
307 |
+
out = out + rm;
|
308 |
+
}
|
309 |
+
}
|
310 |
+
return out;
|
311 |
+
}
|
312 |
+
|
313 |
+
if(uri) {
|
314 |
+
this.parse(uri);
|
315 |
+
}
|
316 |
+
|
317 |
+
},
|
318 |
+
|
319 |
+
|
320 |
+
/*
|
321 |
+
* Usage example:
|
322 |
+
* var myColor = new jscolor.color(myInputElement)
|
323 |
+
*/
|
324 |
+
|
325 |
+
color : function(target, prop) {
|
326 |
+
|
327 |
+
|
328 |
+
this.required = true; // refuse empty values?
|
329 |
+
this.adjust = true; // adjust value to uniform notation?
|
330 |
+
this.hash = false; // prefix color with # symbol?
|
331 |
+
this.caps = true; // uppercase?
|
332 |
+
this.valueElement = target; // value holder
|
333 |
+
this.styleElement = target; // where to reflect current color
|
334 |
+
this.hsv = [0, 0, 1]; // read-only 0-6, 0-1, 0-1
|
335 |
+
this.rgb = [1, 1, 1]; // read-only 0-1, 0-1, 0-1
|
336 |
+
|
337 |
+
this.pickerOnfocus = true; // display picker on focus?
|
338 |
+
this.pickerMode = 'HSV'; // HSV | HVS
|
339 |
+
this.pickerPosition = 'bottom'; // left | right | top | bottom
|
340 |
+
this.pickerFace = 10; // px
|
341 |
+
this.pickerFaceColor = 'ThreeDFace'; // CSS color
|
342 |
+
this.pickerBorder = 1; // px
|
343 |
+
this.pickerBorderColor = 'ThreeDHighlight ThreeDShadow ThreeDShadow ThreeDHighlight'; // CSS color
|
344 |
+
this.pickerInset = 1; // px
|
345 |
+
this.pickerInsetColor = 'ThreeDShadow ThreeDHighlight ThreeDHighlight ThreeDShadow'; // CSS color
|
346 |
+
this.pickerZIndex = 10000;
|
347 |
+
|
348 |
+
|
349 |
+
for(var p in prop) {
|
350 |
+
if(prop.hasOwnProperty(p)) {
|
351 |
+
this[p] = prop[p];
|
352 |
+
}
|
353 |
+
}
|
354 |
+
|
355 |
+
|
356 |
+
this.hidePicker = function() {
|
357 |
+
if(isPickerOwner()) {
|
358 |
+
removePicker();
|
359 |
+
}
|
360 |
+
};
|
361 |
+
|
362 |
+
|
363 |
+
this.showPicker = function() {
|
364 |
+
if(!isPickerOwner()) {
|
365 |
+
var tp = jscolor.getElementPos(target); // target pos
|
366 |
+
var ts = jscolor.getElementSize(target); // target size
|
367 |
+
var vp = jscolor.getViewPos(); // view pos
|
368 |
+
var vs = jscolor.getViewSize(); // view size
|
369 |
+
var ps = [ // picker size
|
370 |
+
2*this.pickerBorder + 4*this.pickerInset + 2*this.pickerFace + jscolor.images.pad[0] + 2*jscolor.images.arrow[0] + jscolor.images.sld[0],
|
371 |
+
2*this.pickerBorder + 2*this.pickerInset + 2*this.pickerFace + jscolor.images.pad[1]
|
372 |
+
];
|
373 |
+
var a, b, c;
|
374 |
+
switch(this.pickerPosition.toLowerCase()) {
|
375 |
+
case 'left': a=1; b=0; c=-1; break;
|
376 |
+
case 'right':a=1; b=0; c=1; break;
|
377 |
+
case 'top': a=0; b=1; c=-1; break;
|
378 |
+
default: a=0; b=1; c=1; break;
|
379 |
+
}
|
380 |
+
var l = (ts[b]+ps[b])/2;
|
381 |
+
var pp = [ // picker pos
|
382 |
+
-vp[a]+tp[a]+ps[a] > vs[a] ?
|
383 |
+
(-vp[a]+tp[a]+ts[a]/2 > vs[a]/2 && tp[a]+ts[a]-ps[a] >= 0 ? tp[a]+ts[a]-ps[a] : tp[a]) :
|
384 |
+
tp[a],
|
385 |
+
-vp[b]+tp[b]+ts[b]+ps[b]-l+l*c > vs[b] ?
|
386 |
+
(-vp[b]+tp[b]+ts[b]/2 > vs[b]/2 && tp[b]+ts[b]-l-l*c >= 0 ? tp[b]+ts[b]-l-l*c : tp[b]+ts[b]-l+l*c) :
|
387 |
+
(tp[b]+ts[b]-l+l*c >= 0 ? tp[b]+ts[b]-l+l*c : tp[b]+ts[b]-l-l*c)
|
388 |
+
];
|
389 |
+
drawPicker(pp[a], pp[b]);
|
390 |
+
}
|
391 |
+
};
|
392 |
+
|
393 |
+
|
394 |
+
this.importColor = function() {
|
395 |
+
if(!valueElement) {
|
396 |
+
this.exportColor();
|
397 |
+
} else {
|
398 |
+
if(!this.adjust) {
|
399 |
+
if(!this.fromString(valueElement.value, leaveValue)) {
|
400 |
+
styleElement.style.backgroundColor = styleElement.jscStyle.backgroundColor;
|
401 |
+
styleElement.style.color = styleElement.jscStyle.color;
|
402 |
+
this.exportColor(leaveValue | leaveStyle);
|
403 |
+
}
|
404 |
+
} else if(!this.required && /^\s*$/.test(valueElement.value)) {
|
405 |
+
valueElement.value = '';
|
406 |
+
styleElement.style.backgroundColor = styleElement.jscStyle.backgroundColor;
|
407 |
+
styleElement.style.color = styleElement.jscStyle.color;
|
408 |
+
this.exportColor(leaveValue | leaveStyle);
|
409 |
+
|
410 |
+
} else if(this.fromString(valueElement.value)) {
|
411 |
+
// OK
|
412 |
+
} else {
|
413 |
+
this.exportColor();
|
414 |
+
}
|
415 |
+
}
|
416 |
+
};
|
417 |
+
|
418 |
+
|
419 |
+
this.exportColor = function(flags) {
|
420 |
+
if(!(flags & leaveValue) && valueElement) {
|
421 |
+
var value = this.toString();
|
422 |
+
if(this.caps) { value = value.toUpperCase(); }
|
423 |
+
if(this.hash) { value = '#'+value; }
|
424 |
+
valueElement.value = value;
|
425 |
+
}
|
426 |
+
if(!(flags & leaveStyle) && styleElement) {
|
427 |
+
styleElement.style.backgroundColor =
|
428 |
+
'#'+this.toString();
|
429 |
+
styleElement.style.color =
|
430 |
+
0.213 * this.rgb[0] +
|
431 |
+
0.715 * this.rgb[1] +
|
432 |
+
0.072 * this.rgb[2]
|
433 |
+
< 0.5 ? '#FFF' : '#000';
|
434 |
+
}
|
435 |
+
if(!(flags & leavePad) && isPickerOwner()) {
|
436 |
+
redrawPad();
|
437 |
+
}
|
438 |
+
if(!(flags & leaveSld) && isPickerOwner()) {
|
439 |
+
redrawSld();
|
440 |
+
}
|
441 |
+
};
|
442 |
+
|
443 |
+
|
444 |
+
this.fromHSV = function(h, s, v, flags) { // null = don't change
|
445 |
+
h<0 && (h=0) || h>6 && (h=6);
|
446 |
+
s<0 && (s=0) || s>1 && (s=1);
|
447 |
+
v<0 && (v=0) || v>1 && (v=1);
|
448 |
+
this.rgb = HSV_RGB(
|
449 |
+
h===null ? this.hsv[0] : (this.hsv[0]=h),
|
450 |
+
s===null ? this.hsv[1] : (this.hsv[1]=s),
|
451 |
+
v===null ? this.hsv[2] : (this.hsv[2]=v)
|
452 |
+
);
|
453 |
+
this.exportColor(flags);
|
454 |
+
};
|
455 |
+
|
456 |
+
|
457 |
+
this.fromRGB = function(r, g, b, flags) { // null = don't change
|
458 |
+
r<0 && (r=0) || r>1 && (r=1);
|
459 |
+
g<0 && (g=0) || g>1 && (g=1);
|
460 |
+
b<0 && (b=0) || b>1 && (b=1);
|
461 |
+
var hsv = RGB_HSV(
|
462 |
+
r===null ? this.rgb[0] : (this.rgb[0]=r),
|
463 |
+
g===null ? this.rgb[1] : (this.rgb[1]=g),
|
464 |
+
b===null ? this.rgb[2] : (this.rgb[2]=b)
|
465 |
+
);
|
466 |
+
if(hsv[0] !== null) {
|
467 |
+
this.hsv[0] = hsv[0];
|
468 |
+
}
|
469 |
+
if(hsv[2] !== 0) {
|
470 |
+
this.hsv[1] = hsv[1];
|
471 |
+
}
|
472 |
+
this.hsv[2] = hsv[2];
|
473 |
+
this.exportColor(flags);
|
474 |
+
};
|
475 |
+
|
476 |
+
|
477 |
+
this.fromString = function(hex, flags) {
|
478 |
+
var m = hex.match(/^\W*([0-9A-F]{3}([0-9A-F]{3})?)\W*$/i);
|
479 |
+
if(!m) {
|
480 |
+
return false;
|
481 |
+
} else {
|
482 |
+
if(m[1].length === 6) { // 6-char notation
|
483 |
+
this.fromRGB(
|
484 |
+
parseInt(m[1].substr(0,2),16) / 255,
|
485 |
+
parseInt(m[1].substr(2,2),16) / 255,
|
486 |
+
parseInt(m[1].substr(4,2),16) / 255,
|
487 |
+
flags
|
488 |
+
);
|
489 |
+
} else { // 3-char notation
|
490 |
+
this.fromRGB(
|
491 |
+
parseInt(m[1].charAt(0)+m[1].charAt(0),16) / 255,
|
492 |
+
parseInt(m[1].charAt(1)+m[1].charAt(1),16) / 255,
|
493 |
+
parseInt(m[1].charAt(2)+m[1].charAt(2),16) / 255,
|
494 |
+
flags
|
495 |
+
);
|
496 |
+
}
|
497 |
+
return true;
|
498 |
+
}
|
499 |
+
};
|
500 |
+
|
501 |
+
|
502 |
+
this.toString = function() {
|
503 |
+
return (
|
504 |
+
(0x100 | Math.round(255*this.rgb[0])).toString(16).substr(1) +
|
505 |
+
(0x100 | Math.round(255*this.rgb[1])).toString(16).substr(1) +
|
506 |
+
(0x100 | Math.round(255*this.rgb[2])).toString(16).substr(1)
|
507 |
+
);
|
508 |
+
};
|
509 |
+
|
510 |
+
|
511 |
+
function RGB_HSV(r, g, b) {
|
512 |
+
var n = Math.min(Math.min(r,g),b);
|
513 |
+
var v = Math.max(Math.max(r,g),b);
|
514 |
+
var m = v - n;
|
515 |
+
if(m === 0) { return [ null, 0, v ]; }
|
516 |
+
var h = r===n ? 3+(b-g)/m : (g===n ? 5+(r-b)/m : 1+(g-r)/m);
|
517 |
+
return [ h===6?0:h, m/v, v ];
|
518 |
+
}
|
519 |
+
|
520 |
+
|
521 |
+
function HSV_RGB(h, s, v) {
|
522 |
+
if(h === null) { return [ v, v, v ]; }
|
523 |
+
var i = Math.floor(h);
|
524 |
+
var f = i%2 ? h-i : 1-(h-i);
|
525 |
+
var m = v * (1 - s);
|
526 |
+
var n = v * (1 - s*f);
|
527 |
+
switch(i) {
|
528 |
+
case 6:
|
529 |
+
case 0: return [v,n,m];
|
530 |
+
case 1: return [n,v,m];
|
531 |
+
case 2: return [m,v,n];
|
532 |
+
case 3: return [m,n,v];
|
533 |
+
case 4: return [n,m,v];
|
534 |
+
case 5: return [v,m,n];
|
535 |
+
}
|
536 |
+
}
|
537 |
+
|
538 |
+
|
539 |
+
function removePicker() {
|
540 |
+
delete jscolor.picker.owner;
|
541 |
+
document.getElementsByTagName('body')[0].removeChild(jscolor.picker.boxB);
|
542 |
+
}
|
543 |
+
|
544 |
+
|
545 |
+
function drawPicker(x, y) {
|
546 |
+
if(!jscolor.picker) {
|
547 |
+
jscolor.picker = {
|
548 |
+
box : document.createElement('div'),
|
549 |
+
boxB : document.createElement('div'),
|
550 |
+
pad : document.createElement('div'),
|
551 |
+
padB : document.createElement('div'),
|
552 |
+
padM : document.createElement('div'),
|
553 |
+
sld : document.createElement('div'),
|
554 |
+
sldB : document.createElement('div'),
|
555 |
+
sldM : document.createElement('div')
|
556 |
+
};
|
557 |
+
for(var i=0,segSize=4; i<jscolor.images.sld[1]; i+=segSize) {
|
558 |
+
var seg = document.createElement('div');
|
559 |
+
seg.style.height = segSize+'px';
|
560 |
+
seg.style.fontSize = '1px';
|
561 |
+
seg.style.lineHeight = '0';
|
562 |
+
jscolor.picker.sld.appendChild(seg);
|
563 |
+
}
|
564 |
+
jscolor.picker.sldB.appendChild(jscolor.picker.sld);
|
565 |
+
jscolor.picker.box.appendChild(jscolor.picker.sldB);
|
566 |
+
jscolor.picker.box.appendChild(jscolor.picker.sldM);
|
567 |
+
jscolor.picker.padB.appendChild(jscolor.picker.pad);
|
568 |
+
jscolor.picker.box.appendChild(jscolor.picker.padB);
|
569 |
+
jscolor.picker.box.appendChild(jscolor.picker.padM);
|
570 |
+
jscolor.picker.boxB.appendChild(jscolor.picker.box);
|
571 |
+
}
|
572 |
+
|
573 |
+
var p = jscolor.picker;
|
574 |
+
|
575 |
+
// recompute controls positions
|
576 |
+
posPad = [
|
577 |
+
x+THIS.pickerBorder+THIS.pickerFace+THIS.pickerInset,
|
578 |
+
y+THIS.pickerBorder+THIS.pickerFace+THIS.pickerInset ];
|
579 |
+
posSld = [
|
580 |
+
null,
|
581 |
+
y+THIS.pickerBorder+THIS.pickerFace+THIS.pickerInset ];
|
582 |
+
|
583 |
+
// controls interaction
|
584 |
+
p.box.onmouseup =
|
585 |
+
p.box.onmouseout = function() { target.focus(); };
|
586 |
+
p.box.onmousedown = function() { abortBlur=true; };
|
587 |
+
p.box.onmousemove = function(e) { holdPad && setPad(e); holdSld && setSld(e); };
|
588 |
+
p.padM.onmouseup =
|
589 |
+
p.padM.onmouseout = function() { if(holdPad) { holdPad=false; jscolor.fireEvent(valueElement,'change'); } };
|
590 |
+
p.padM.onmousedown = function(e) { holdPad=true; setPad(e); };
|
591 |
+
p.sldM.onmouseup =
|
592 |
+
p.sldM.onmouseout = function() { if(holdSld) { holdSld=false; jscolor.fireEvent(valueElement,'change'); } };
|
593 |
+
p.sldM.onmousedown = function(e) { holdSld=true; setSld(e); };
|
594 |
+
|
595 |
+
// picker
|
596 |
+
p.box.style.width = 4*THIS.pickerInset + 2*THIS.pickerFace + jscolor.images.pad[0] + 2*jscolor.images.arrow[0] + jscolor.images.sld[0] + 'px';
|
597 |
+
p.box.style.height = 2*THIS.pickerInset + 2*THIS.pickerFace + jscolor.images.pad[1] + 'px';
|
598 |
+
|
599 |
+
// picker border
|
600 |
+
p.boxB.style.position = 'absolute';
|
601 |
+
p.boxB.style.clear = 'both';
|
602 |
+
p.boxB.style.left = x+'px';
|
603 |
+
p.boxB.style.top = y+'px';
|
604 |
+
p.boxB.style.zIndex = THIS.pickerZIndex;
|
605 |
+
p.boxB.style.border = THIS.pickerBorder+'px solid';
|
606 |
+
p.boxB.style.borderColor = THIS.pickerBorderColor;
|
607 |
+
p.boxB.style.background = THIS.pickerFaceColor;
|
608 |
+
|
609 |
+
// pad image
|
610 |
+
p.pad.style.width = jscolor.images.pad[0]+'px';
|
611 |
+
p.pad.style.height = jscolor.images.pad[1]+'px';
|
612 |
+
|
613 |
+
// pad border
|
614 |
+
p.padB.style.position = 'absolute';
|
615 |
+
p.padB.style.left = THIS.pickerFace+'px';
|
616 |
+
p.padB.style.top = THIS.pickerFace+'px';
|
617 |
+
p.padB.style.border = THIS.pickerInset+'px solid';
|
618 |
+
p.padB.style.borderColor = THIS.pickerInsetColor;
|
619 |
+
|
620 |
+
// pad mouse area
|
621 |
+
p.padM.style.position = 'absolute';
|
622 |
+
p.padM.style.left = '0';
|
623 |
+
p.padM.style.top = '0';
|
624 |
+
p.padM.style.width = THIS.pickerFace + 2*THIS.pickerInset + jscolor.images.pad[0] + jscolor.images.arrow[0] + 'px';
|
625 |
+
p.padM.style.height = p.box.style.height;
|
626 |
+
p.padM.style.cursor = 'crosshair';
|
627 |
+
|
628 |
+
// slider image
|
629 |
+
p.sld.style.overflow = 'hidden';
|
630 |
+
p.sld.style.width = jscolor.images.sld[0]+'px';
|
631 |
+
p.sld.style.height = jscolor.images.sld[1]+'px';
|
632 |
+
|
633 |
+
// slider border
|
634 |
+
p.sldB.style.position = 'absolute';
|
635 |
+
p.sldB.style.right = THIS.pickerFace+'px';
|
636 |
+
p.sldB.style.top = THIS.pickerFace+'px';
|
637 |
+
p.sldB.style.border = THIS.pickerInset+'px solid';
|
638 |
+
p.sldB.style.borderColor = THIS.pickerInsetColor;
|
639 |
+
|
640 |
+
// slider mouse area
|
641 |
+
p.sldM.style.position = 'absolute';
|
642 |
+
p.sldM.style.right = '0';
|
643 |
+
p.sldM.style.top = '0';
|
644 |
+
p.sldM.style.width = jscolor.images.sld[0] + jscolor.images.arrow[0] + THIS.pickerFace + 2*THIS.pickerInset + 'px';
|
645 |
+
p.sldM.style.height = p.box.style.height;
|
646 |
+
try {
|
647 |
+
p.sldM.style.cursor = 'pointer';
|
648 |
+
} catch(eOldIE) {
|
649 |
+
p.sldM.style.cursor = 'hand';
|
650 |
+
}
|
651 |
+
|
652 |
+
// load images in optimal order
|
653 |
+
switch(modeID) {
|
654 |
+
case 0: var padImg = 'hs.png'; break;
|
655 |
+
case 1: var padImg = 'hv.png'; break;
|
656 |
+
}
|
657 |
+
p.padM.style.background = "url('"+jscolor.getDir()+"cross.gif') no-repeat";
|
658 |
+
p.sldM.style.background = "url('"+jscolor.getDir()+"arrow.gif') no-repeat";
|
659 |
+
p.pad.style.background = "url('"+jscolor.getDir()+padImg+"') 0 0 no-repeat";
|
660 |
+
|
661 |
+
// place pointers
|
662 |
+
redrawPad();
|
663 |
+
redrawSld();
|
664 |
+
|
665 |
+
jscolor.picker.owner = THIS;
|
666 |
+
document.getElementsByTagName('body')[0].appendChild(p.boxB);
|
667 |
+
}
|
668 |
+
|
669 |
+
|
670 |
+
function redrawPad() {
|
671 |
+
// redraw the pad pointer
|
672 |
+
switch(modeID) {
|
673 |
+
case 0: var yComponent = 1; break;
|
674 |
+
case 1: var yComponent = 2; break;
|
675 |
+
}
|
676 |
+
var x = Math.round((THIS.hsv[0]/6) * (jscolor.images.pad[0]-1));
|
677 |
+
var y = Math.round((1-THIS.hsv[yComponent]) * (jscolor.images.pad[1]-1));
|
678 |
+
jscolor.picker.padM.style.backgroundPosition =
|
679 |
+
(THIS.pickerFace+THIS.pickerInset+x - Math.floor(jscolor.images.cross[0]/2)) + 'px ' +
|
680 |
+
(THIS.pickerFace+THIS.pickerInset+y - Math.floor(jscolor.images.cross[1]/2)) + 'px';
|
681 |
+
|
682 |
+
// redraw the slider image
|
683 |
+
var seg = jscolor.picker.sld.childNodes;
|
684 |
+
|
685 |
+
switch(modeID) {
|
686 |
+
case 0:
|
687 |
+
var rgb = HSV_RGB(THIS.hsv[0], THIS.hsv[1], 1);
|
688 |
+
for(var i=0; i<seg.length; i+=1) {
|
689 |
+
seg[i].style.backgroundColor = 'rgb('+
|
690 |
+
(rgb[0]*(1-i/seg.length)*100)+'%,'+
|
691 |
+
(rgb[1]*(1-i/seg.length)*100)+'%,'+
|
692 |
+
(rgb[2]*(1-i/seg.length)*100)+'%)';
|
693 |
+
}
|
694 |
+
break;
|
695 |
+
case 1:
|
696 |
+
var rgb, s, c = [ THIS.hsv[2], 0, 0 ];
|
697 |
+
var i = Math.floor(THIS.hsv[0]);
|
698 |
+
var f = i%2 ? THIS.hsv[0]-i : 1-(THIS.hsv[0]-i);
|
699 |
+
switch(i) {
|
700 |
+
case 6:
|
701 |
+
case 0: rgb=[0,1,2]; break;
|
702 |
+
case 1: rgb=[1,0,2]; break;
|
703 |
+
case 2: rgb=[2,0,1]; break;
|
704 |
+
case 3: rgb=[2,1,0]; break;
|
705 |
+
case 4: rgb=[1,2,0]; break;
|
706 |
+
case 5: rgb=[0,2,1]; break;
|
707 |
+
}
|
708 |
+
for(var i=0; i<seg.length; i+=1) {
|
709 |
+
s = 1 - 1/(seg.length-1)*i;
|
710 |
+
c[1] = c[0] * (1 - s*f);
|
711 |
+
c[2] = c[0] * (1 - s);
|
712 |
+
seg[i].style.backgroundColor = 'rgb('+
|
713 |
+
(c[rgb[0]]*100)+'%,'+
|
714 |
+
(c[rgb[1]]*100)+'%,'+
|
715 |
+
(c[rgb[2]]*100)+'%)';
|
716 |
+
}
|
717 |
+
break;
|
718 |
+
}
|
719 |
+
}
|
720 |
+
|
721 |
+
|
722 |
+
function redrawSld() {
|
723 |
+
// redraw the slider pointer
|
724 |
+
switch(modeID) {
|
725 |
+
case 0: var yComponent = 2; break;
|
726 |
+
case 1: var yComponent = 1; break;
|
727 |
+
}
|
728 |
+
var y = Math.round((1-THIS.hsv[yComponent]) * (jscolor.images.sld[1]-1));
|
729 |
+
jscolor.picker.sldM.style.backgroundPosition =
|
730 |
+
'0 ' + (THIS.pickerFace+THIS.pickerInset+y - Math.floor(jscolor.images.arrow[1]/2)) + 'px';
|
731 |
+
}
|
732 |
+
|
733 |
+
|
734 |
+
function isPickerOwner() {
|
735 |
+
return jscolor.picker && jscolor.picker.owner === THIS;
|
736 |
+
}
|
737 |
+
|
738 |
+
|
739 |
+
function blurTarget() {
|
740 |
+
if(valueElement === target) {
|
741 |
+
THIS.importColor();
|
742 |
+
}
|
743 |
+
if(THIS.pickerOnfocus) {
|
744 |
+
THIS.hidePicker();
|
745 |
+
}
|
746 |
+
}
|
747 |
+
|
748 |
+
|
749 |
+
function blurValue() {
|
750 |
+
if(valueElement !== target) {
|
751 |
+
THIS.importColor();
|
752 |
+
}
|
753 |
+
}
|
754 |
+
|
755 |
+
|
756 |
+
function setPad(e) {
|
757 |
+
var posM = jscolor.getMousePos(e);
|
758 |
+
var x = posM[0]-posPad[0];
|
759 |
+
var y = posM[1]-posPad[1];
|
760 |
+
switch(modeID) {
|
761 |
+
case 0: THIS.fromHSV(x*(6/(jscolor.images.pad[0]-1)), 1 - y/(jscolor.images.pad[1]-1), null, leaveSld); break;
|
762 |
+
case 1: THIS.fromHSV(x*(6/(jscolor.images.pad[0]-1)), null, 1 - y/(jscolor.images.pad[1]-1), leaveSld); break;
|
763 |
+
}
|
764 |
+
}
|
765 |
+
|
766 |
+
|
767 |
+
function setSld(e) {
|
768 |
+
var posM = jscolor.getMousePos(e);
|
769 |
+
var y = posM[1]-posPad[1];
|
770 |
+
switch(modeID) {
|
771 |
+
case 0: THIS.fromHSV(null, null, 1 - y/(jscolor.images.sld[1]-1), leavePad); break;
|
772 |
+
case 1: THIS.fromHSV(null, 1 - y/(jscolor.images.sld[1]-1), null, leavePad); break;
|
773 |
+
}
|
774 |
+
}
|
775 |
+
|
776 |
+
|
777 |
+
var THIS = this;
|
778 |
+
var modeID = this.pickerMode.toLowerCase()==='hvs' ? 1 : 0;
|
779 |
+
var abortBlur = false;
|
780 |
+
var
|
781 |
+
valueElement = jscolor.fetchElement(this.valueElement),
|
782 |
+
styleElement = jscolor.fetchElement(this.styleElement);
|
783 |
+
var
|
784 |
+
holdPad = false,
|
785 |
+
holdSld = false;
|
786 |
+
var
|
787 |
+
posPad,
|
788 |
+
posSld;
|
789 |
+
var
|
790 |
+
leaveValue = 1<<0,
|
791 |
+
leaveStyle = 1<<1,
|
792 |
+
leavePad = 1<<2,
|
793 |
+
leaveSld = 1<<3;
|
794 |
+
|
795 |
+
// target
|
796 |
+
jscolor.addEvent(target, 'focus', function() {
|
797 |
+
if(THIS.pickerOnfocus) { THIS.showPicker(); }
|
798 |
+
});
|
799 |
+
jscolor.addEvent(target, 'blur', function() {
|
800 |
+
if(!abortBlur) {
|
801 |
+
window.setTimeout(function(){ abortBlur || blurTarget(); abortBlur=false; }, 0);
|
802 |
+
} else {
|
803 |
+
abortBlur = false;
|
804 |
+
}
|
805 |
+
});
|
806 |
+
|
807 |
+
// valueElement
|
808 |
+
if(valueElement) {
|
809 |
+
var updateField = function() {
|
810 |
+
THIS.fromString(valueElement.value, leaveValue);
|
811 |
+
};
|
812 |
+
jscolor.addEvent(valueElement, 'keyup', updateField);
|
813 |
+
jscolor.addEvent(valueElement, 'input', updateField);
|
814 |
+
jscolor.addEvent(valueElement, 'blur', blurValue);
|
815 |
+
valueElement.setAttribute('autocomplete', 'off');
|
816 |
+
}
|
817 |
+
|
818 |
+
// styleElement
|
819 |
+
if(styleElement) {
|
820 |
+
styleElement.jscStyle = {
|
821 |
+
backgroundColor : styleElement.style.backgroundColor,
|
822 |
+
color : styleElement.style.color
|
823 |
+
};
|
824 |
+
}
|
825 |
+
|
826 |
+
// require images
|
827 |
+
switch(modeID) {
|
828 |
+
case 0: jscolor.requireImage('hs.png'); break;
|
829 |
+
case 1: jscolor.requireImage('hv.png'); break;
|
830 |
+
}
|
831 |
+
jscolor.requireImage('cross.gif');
|
832 |
+
jscolor.requireImage('arrow.gif');
|
833 |
+
|
834 |
+
this.importColor();
|
835 |
+
}
|
836 |
+
|
837 |
+
};
|
838 |
+
|
839 |
+
|
840 |
+
jscolor.install();
|
js/shero/maintenance/maintenance.js
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
jQuery(function() {
|
2 |
+
var url = jQuery('#maintenance_alert_url').text();
|
3 |
+
jQuery.ajax({
|
4 |
+
type: "POST",
|
5 |
+
url: url,
|
6 |
+
success: function (result) {
|
7 |
+
var results = result.split(',');
|
8 |
+
if (results[0] == '' || results[0] == 'inactive') {
|
9 |
+
return;
|
10 |
+
} else {
|
11 |
+
var alert = '<div class="alert-div"><strong>'+ results[0] +'</strong><button class="trigger" onclick="jQuery(\'#alert\').hide();"><strong>X</strong></button></div>';
|
12 |
+
jQuery('#alert').html(alert);
|
13 |
+
jQuery('.alert-div').css({"background-color": "#"+results[1], "textAlign": "center", "color": "#"+results[2]});
|
14 |
+
jQuery('.trigger').css({"background-color": "#"+results[1], "float": "right", "border":"none","margin-right":"5px"});
|
15 |
+
jQuery(window).scroll(function(){
|
16 |
+
var alertdiv = jQuery('.alert-div');
|
17 |
+
var scroll = jQuery(window).scrollTop();
|
18 |
+
console.log(scroll);
|
19 |
+
if (scroll >= 1)
|
20 |
+
{
|
21 |
+
alertdiv.addClass('fixed');
|
22 |
+
}
|
23 |
+
else {
|
24 |
+
alertdiv.removeClass('fixed');
|
25 |
+
}
|
26 |
+
});
|
27 |
+
}
|
28 |
+
}
|
29 |
+
});
|
30 |
+
});
|
package.xml
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>Shero_Maintenance</name>
|
4 |
+
<version>1.0.0</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license uri="https://opensource.org/licenses/osl-3.0.php">OSL</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>Put a website on maintenance mode, whitelist IPs, and block dev and staging websites from general visitors.</summary>
|
10 |
+
<description>Brief Description: Put a website on maintenance mode, whitelist IPs, and block dev and staging websites from general visitors.
|
11 |
+

|
12 |
+
Detailed Description: This extension can be used for the following three purposes:
|
13 |
+

|
14 |
+
1) Put a Magento website on maintenance mode where the live website goes down and only certain IP numbers can view it. Setting a website on Maintenance Mode is useful during deployments.
|
15 |
+

|
16 |
+
2) Show visitors a banner saying that your website will be undergoing maintenance from this date to that date.
|
17 |
+

|
18 |
+
3) Use this extension to block visitors  from accessing your dev and staging environments. 
|
19 |
+
Enjoy!</description>
|
20 |
+
<notes>This extension can put a website on maintenance mode, whitelist IPs, and block dev and staging websites from general visitors.</notes>
|
21 |
+
<authors><author><name>SheroDesigns</name><user>SheroDesigns</user><email>support@sherodesigns.com</email></author></authors>
|
22 |
+
<date>2016-04-22</date>
|
23 |
+
<time>13:06:34</time>
|
24 |
+
<contents><target name="magelocal"><dir name="Shero"><dir name="Maintenance"><dir name="Helper"><file name="Data.php" hash="425b32784208591848dd4368aa8d6f13"/></dir><dir name="Model"><file name="Observer.php" hash="f3624a3451e2397c0a423f79c47269bc"/></dir><dir name="controllers"><file name="IndexController.php" hash="666697c0efefaa05e4142fc630f8ac51"/></dir><dir name="etc"><file name="config.xml" hash="b725a94b7943515bfe31a71460f3aae9"/><file name="system.xml" hash="fc07d39cf4e7afb517c147595b285bc8"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Shero_Maintenance.xml" hash="5608e7bd627d336dfd488f15fdbc518b"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="picker.xml" hash="2c2bcd8b7c9318b1b94eb0fdef1cab63"/></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><dir name="shero"><file name="maintenance.xml" hash="f6ad3771595e91800796d316a5dcf9fe"/></dir></dir><dir name="template"><dir name="maintenance"><dir name="page"><dir name="html"><file name="notices.phtml" hash="404909f5dfdf266906bfb4d881aa7a38"/></dir></dir></dir></dir></dir></dir></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="images"><dir name="shero"><file name="shero-extension-banner_thumb.png" hash="9bee22ff9ad91af7f0f5bf1efca0fa04"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="css"><dir name="shero"><file name="maintenance.css" hash="20b1a33a0186505e20e379a07b965e6f"/></dir></dir></dir></dir></dir></target><target name="mageweb"><dir name="js"><dir name="jscolor"><file name="arrow.gif" hash="5034704a76cd55c1cbcbc58ea6bf523f"/><file name="cross.gif" hash="ba9a274b9323753cd95bc3b1eb2f4e5f"/><file name="demo.html" hash="edf71251cb2be20322d2efb00aee86a6"/><file name="hs.png" hash="fefa1a03d92ebad25c88dca94a0b63db"/><file name="hv.png" hash="990d71cada17da100653636cf8490884"/><file name="jscolor.js" hash="b65a1505390592ac6c0177d6b84774e0"/></dir><dir name="shero"><dir name="maintenance"><file name="maintenance.js" hash="459496bd0a1b17f556e60417f38ec034"/></dir></dir></dir></target></contents>
|
25 |
+
<compatible/>
|
26 |
+
<dependencies><required><php><min>5.4.0</min><max>7.0.0</max></php></required></dependencies>
|
27 |
+
</package>
|
skin/adminhtml/default/default/images/shero/shero-extension-banner_thumb.png
ADDED
Binary file
|
skin/frontend/base/default/css/shero/maintenance.css
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.fixed {
|
2 |
+
position: fixed;
|
3 |
+
top:0; left:0;
|
4 |
+
width: 100%;
|
5 |
+
z-index: 1000;
|
6 |
+
}
|