Version Notes
New
Download this release
Release Info
Developer | Amatya |
Extension | intell_colorswatch |
Version | 1.0.0.1 |
Comparing to | |
See all releases |
Version 1.0.0.1
- app/code/local/Intell/Colorswatch/Block/Adminhtml/Colorswatch.php +20 -0
- app/code/local/Intell/Colorswatch/Block/Adminhtml/Colorswatch/Edit.php +45 -0
- app/code/local/Intell/Colorswatch/Block/Adminhtml/Colorswatch/Edit/Form.php +19 -0
- app/code/local/Intell/Colorswatch/Block/Adminhtml/Colorswatch/Edit/Tab/Form.php +59 -0
- app/code/local/Intell/Colorswatch/Block/Adminhtml/Colorswatch/Edit/Tabs.php +24 -0
- app/code/local/Intell/Colorswatch/Block/Adminhtml/Colorswatch/Grid.php +117 -0
- app/code/local/Intell/Colorswatch/Block/Colorswatch.php +61 -0
- app/code/local/Intell/Colorswatch/Helper/Data.php +6 -0
- app/code/local/Intell/Colorswatch/Model/Colorswatch.php +10 -0
- app/code/local/Intell/Colorswatch/Model/Mysql4/Colorswatch.php +10 -0
- app/code/local/Intell/Colorswatch/Model/Mysql4/Colorswatch/Collection.php +10 -0
- app/code/local/Intell/Colorswatch/Model/Status.php +15 -0
- app/code/local/Intell/Colorswatch/controllers/Adminhtml/ColorswatchController.php +264 -0
- app/code/local/Intell/Colorswatch/controllers/IndexController.php +47 -0
- app/code/local/Intell/Colorswatch/etc/XX-adminhtml.xml +29 -0
- app/code/local/Intell/Colorswatch/etc/config.xml +139 -0
- app/code/local/Intell/Colorswatch/etc/system.xml +38 -0
- app/code/local/Intell/Colorswatch/sql/colorswatch_setup/mysql4-install-0.1.0.php +24 -0
- app/design/adminhtml/default/default/layout/colorswatch.xml +8 -0
- app/design/frontend/default/default/layout/colorswatch.xml +16 -0
- app/design/frontend/default/default/template/colorswatch/colorswatch.phtml +65 -0
- app/design/frontend/default/default/template/colorswatch/view.phtml +218 -0
- app/etc/modules/Intell_Colorswatch.xml +17 -0
- package.xml +18 -0
- skin/frontend/default/default/colorswatch/js/featuredimagezoomer.js +233 -0
app/code/local/Intell/Colorswatch/Block/Adminhtml/Colorswatch.php
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Intell_Colorswatch_Block_Adminhtml_Colorswatch extends Mage_Adminhtml_Block_Widget_Grid_Container
|
3 |
+
{
|
4 |
+
public function __construct()
|
5 |
+
{
|
6 |
+
$this->_controller = 'adminhtml_colorswatch';
|
7 |
+
$this->_blockGroup = 'colorswatch';
|
8 |
+
$this->_headerText = Mage::helper('colorswatch')->__('Item Manager');
|
9 |
+
$this->_addButtonLabel = Mage::helper('colorswatch')->__('Add Item');
|
10 |
+
parent::__construct();
|
11 |
+
|
12 |
+
$this->_removeButton('add');
|
13 |
+
$this->_addButton('load', array(
|
14 |
+
'label' => Mage::helper('colorswatch')->__('Load Attribute Values'),
|
15 |
+
'onclick' => "setLocation('".$this->getUrl('*/*/install')."')",
|
16 |
+
|
17 |
+
));
|
18 |
+
|
19 |
+
}
|
20 |
+
}
|
app/code/local/Intell/Colorswatch/Block/Adminhtml/Colorswatch/Edit.php
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Intell_Colorswatch_Block_Adminhtml_Colorswatch_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
|
4 |
+
{
|
5 |
+
public function __construct()
|
6 |
+
{
|
7 |
+
parent::__construct();
|
8 |
+
|
9 |
+
$this->_objectId = 'id';
|
10 |
+
$this->_blockGroup = 'colorswatch';
|
11 |
+
$this->_controller = 'adminhtml_colorswatch';
|
12 |
+
|
13 |
+
$this->_updateButton('save', 'label', Mage::helper('colorswatch')->__('Save Item'));
|
14 |
+
$this->_updateButton('delete', 'label', Mage::helper('colorswatch')->__('Delete Item'));
|
15 |
+
|
16 |
+
$this->_addButton('saveandcontinue', array(
|
17 |
+
'label' => Mage::helper('adminhtml')->__('Save And Continue Edit'),
|
18 |
+
'onclick' => 'saveAndContinueEdit()',
|
19 |
+
'class' => 'save',
|
20 |
+
), -100);
|
21 |
+
|
22 |
+
$this->_formScripts[] = "
|
23 |
+
function toggleEditor() {
|
24 |
+
if (tinyMCE.getInstanceById('colorswatch_content') == null) {
|
25 |
+
tinyMCE.execCommand('mceAddControl', false, 'colorswatch_content');
|
26 |
+
} else {
|
27 |
+
tinyMCE.execCommand('mceRemoveControl', false, 'colorswatch_content');
|
28 |
+
}
|
29 |
+
}
|
30 |
+
|
31 |
+
function saveAndContinueEdit(){
|
32 |
+
editForm.submit($('edit_form').action+'back/edit/');
|
33 |
+
}
|
34 |
+
";
|
35 |
+
}
|
36 |
+
|
37 |
+
public function getHeaderText()
|
38 |
+
{
|
39 |
+
if( Mage::registry('colorswatch_data') && Mage::registry('colorswatch_data')->getId() ) {
|
40 |
+
return Mage::helper('colorswatch')->__("Edit Item '%s'", $this->htmlEscape(Mage::registry('colorswatch_data')->getTitle()));
|
41 |
+
} else {
|
42 |
+
return Mage::helper('colorswatch')->__('Add Item');
|
43 |
+
}
|
44 |
+
}
|
45 |
+
}
|
app/code/local/Intell/Colorswatch/Block/Adminhtml/Colorswatch/Edit/Form.php
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Intell_Colorswatch_Block_Adminhtml_Colorswatch_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
|
4 |
+
{
|
5 |
+
protected function _prepareForm()
|
6 |
+
{
|
7 |
+
$form = new Varien_Data_Form(array(
|
8 |
+
'id' => 'edit_form',
|
9 |
+
'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))),
|
10 |
+
'method' => 'post',
|
11 |
+
'enctype' => 'multipart/form-data'
|
12 |
+
)
|
13 |
+
);
|
14 |
+
|
15 |
+
$form->setUseContainer(true);
|
16 |
+
$this->setForm($form);
|
17 |
+
return parent::_prepareForm();
|
18 |
+
}
|
19 |
+
}
|
app/code/local/Intell/Colorswatch/Block/Adminhtml/Colorswatch/Edit/Tab/Form.php
ADDED
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Intell_Colorswatch_Block_Adminhtml_Colorswatch_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form
|
4 |
+
{
|
5 |
+
protected function _prepareForm()
|
6 |
+
{
|
7 |
+
$form = new Varien_Data_Form();
|
8 |
+
$this->setForm($form);
|
9 |
+
$fieldset = $form->addFieldset('colorswatch_form', array('legend'=>Mage::helper('colorswatch')->__('Item information')));
|
10 |
+
|
11 |
+
$fieldset->addField('title', 'text', array(
|
12 |
+
'label' => Mage::helper('colorswatch')->__('Title'),
|
13 |
+
'class' => 'required-entry',
|
14 |
+
'required' => true,
|
15 |
+
'name' => 'title',
|
16 |
+
));
|
17 |
+
|
18 |
+
$fieldset->addField('filename', 'image', array(
|
19 |
+
'label' => Mage::helper('colorswatch')->__('File'),
|
20 |
+
'required' => false,
|
21 |
+
'name' => 'filename',
|
22 |
+
));
|
23 |
+
|
24 |
+
/*$fieldset->addField('status', 'select', array(
|
25 |
+
'label' => Mage::helper('colorswatch')->__('Status'),
|
26 |
+
'name' => 'status',
|
27 |
+
'values' => array(
|
28 |
+
array(
|
29 |
+
'value' => 1,
|
30 |
+
'label' => Mage::helper('colorswatch')->__('Enabled'),
|
31 |
+
),
|
32 |
+
|
33 |
+
array(
|
34 |
+
'value' => 2,
|
35 |
+
'label' => Mage::helper('colorswatch')->__('Disabled'),
|
36 |
+
),
|
37 |
+
),
|
38 |
+
));
|
39 |
+
*/
|
40 |
+
|
41 |
+
$fieldset->addField('content', 'editor', array(
|
42 |
+
'name' => 'content',
|
43 |
+
'label' => Mage::helper('colorswatch')->__('Content'),
|
44 |
+
'title' => Mage::helper('colorswatch')->__('Content'),
|
45 |
+
'style' => 'width:700px; height:500px;',
|
46 |
+
'wysiwyg' => false,
|
47 |
+
'required' => true,
|
48 |
+
));
|
49 |
+
|
50 |
+
if ( Mage::getSingleton('adminhtml/session')->getColorswatchData() )
|
51 |
+
{
|
52 |
+
$form->setValues(Mage::getSingleton('adminhtml/session')->getColorswatchData());
|
53 |
+
Mage::getSingleton('adminhtml/session')->setColorswatchData(null);
|
54 |
+
} elseif ( Mage::registry('colorswatch_data') ) {
|
55 |
+
$form->setValues(Mage::registry('colorswatch_data')->getData());
|
56 |
+
}
|
57 |
+
return parent::_prepareForm();
|
58 |
+
}
|
59 |
+
}
|
app/code/local/Intell/Colorswatch/Block/Adminhtml/Colorswatch/Edit/Tabs.php
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Intell_Colorswatch_Block_Adminhtml_Colorswatch_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
|
4 |
+
{
|
5 |
+
|
6 |
+
public function __construct()
|
7 |
+
{
|
8 |
+
parent::__construct();
|
9 |
+
$this->setId('colorswatch_tabs');
|
10 |
+
$this->setDestElementId('edit_form');
|
11 |
+
$this->setTitle(Mage::helper('colorswatch')->__('Item Information'));
|
12 |
+
}
|
13 |
+
|
14 |
+
protected function _beforeToHtml()
|
15 |
+
{
|
16 |
+
$this->addTab('form_section', array(
|
17 |
+
'label' => Mage::helper('colorswatch')->__('Item Information'),
|
18 |
+
'title' => Mage::helper('colorswatch')->__('Item Information'),
|
19 |
+
'content' => $this->getLayout()->createBlock('colorswatch/adminhtml_colorswatch_edit_tab_form')->toHtml(),
|
20 |
+
));
|
21 |
+
|
22 |
+
return parent::_beforeToHtml();
|
23 |
+
}
|
24 |
+
}
|
app/code/local/Intell/Colorswatch/Block/Adminhtml/Colorswatch/Grid.php
ADDED
@@ -0,0 +1,117 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Intell_Colorswatch_Block_Adminhtml_Colorswatch_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
4 |
+
{
|
5 |
+
public function __construct()
|
6 |
+
{
|
7 |
+
parent::__construct();
|
8 |
+
$this->setId('colorswatchGrid');
|
9 |
+
$this->setDefaultSort('colorswatch_id');
|
10 |
+
$this->setDefaultDir('ASC');
|
11 |
+
$this->setSaveParametersInSession(true);
|
12 |
+
}
|
13 |
+
|
14 |
+
protected function _prepareCollection()
|
15 |
+
{
|
16 |
+
$collection = Mage::getModel('colorswatch/colorswatch')->getCollection();
|
17 |
+
$this->setCollection($collection);
|
18 |
+
return parent::_prepareCollection();
|
19 |
+
}
|
20 |
+
|
21 |
+
protected function _prepareColumns()
|
22 |
+
{
|
23 |
+
$this->addColumn('colorswatch_id', array(
|
24 |
+
'header' => Mage::helper('colorswatch')->__('ID'),
|
25 |
+
'align' =>'right',
|
26 |
+
'width' => '50px',
|
27 |
+
'index' => 'colorswatch_id',
|
28 |
+
));
|
29 |
+
|
30 |
+
$this->addColumn('title', array(
|
31 |
+
'header' => Mage::helper('colorswatch')->__('Title'),
|
32 |
+
'align' =>'left',
|
33 |
+
'index' => 'title',
|
34 |
+
));
|
35 |
+
|
36 |
+
/*
|
37 |
+
$this->addColumn('content', array(
|
38 |
+
'header' => Mage::helper('colorswatch')->__('Item Content'),
|
39 |
+
'width' => '150px',
|
40 |
+
'index' => 'content',
|
41 |
+
));
|
42 |
+
*/
|
43 |
+
|
44 |
+
/*$this->addColumn('status', array(
|
45 |
+
'header' => Mage::helper('colorswatch')->__('Status'),
|
46 |
+
'align' => 'left',
|
47 |
+
'width' => '80px',
|
48 |
+
'index' => 'status',
|
49 |
+
'type' => 'options',
|
50 |
+
'options' => array(
|
51 |
+
1 => 'Enabled',
|
52 |
+
2 => 'Disabled',
|
53 |
+
),
|
54 |
+
));
|
55 |
+
*/
|
56 |
+
|
57 |
+
$this->addColumn('action',
|
58 |
+
array(
|
59 |
+
'header' => Mage::helper('colorswatch')->__('Action'),
|
60 |
+
'width' => '100',
|
61 |
+
'type' => 'action',
|
62 |
+
'getter' => 'getId',
|
63 |
+
'actions' => array(
|
64 |
+
array(
|
65 |
+
'caption' => Mage::helper('colorswatch')->__('Edit'),
|
66 |
+
'url' => array('base'=> '*/*/edit'),
|
67 |
+
'field' => 'id'
|
68 |
+
)
|
69 |
+
),
|
70 |
+
'filter' => false,
|
71 |
+
'sortable' => false,
|
72 |
+
'index' => 'stores',
|
73 |
+
'is_system' => true,
|
74 |
+
));
|
75 |
+
|
76 |
+
$this->addExportType('*/*/exportCsv', Mage::helper('colorswatch')->__('CSV'));
|
77 |
+
$this->addExportType('*/*/exportXml', Mage::helper('colorswatch')->__('XML'));
|
78 |
+
|
79 |
+
return parent::_prepareColumns();
|
80 |
+
}
|
81 |
+
|
82 |
+
protected function _prepareMassaction()
|
83 |
+
{
|
84 |
+
$this->setMassactionIdField('colorswatch_id');
|
85 |
+
$this->getMassactionBlock()->setFormFieldName('colorswatch');
|
86 |
+
|
87 |
+
$this->getMassactionBlock()->addItem('delete', array(
|
88 |
+
'label' => Mage::helper('colorswatch')->__('Delete'),
|
89 |
+
'url' => $this->getUrl('*/*/massDelete'),
|
90 |
+
'confirm' => Mage::helper('colorswatch')->__('Are you sure?')
|
91 |
+
));
|
92 |
+
|
93 |
+
$statuses = Mage::getSingleton('colorswatch/status')->getOptionArray();
|
94 |
+
|
95 |
+
array_unshift($statuses, array('label'=>'', 'value'=>''));
|
96 |
+
$this->getMassactionBlock()->addItem('status', array(
|
97 |
+
'label'=> Mage::helper('colorswatch')->__('Change status'),
|
98 |
+
'url' => $this->getUrl('*/*/massStatus', array('_current'=>true)),
|
99 |
+
'additional' => array(
|
100 |
+
'visibility' => array(
|
101 |
+
'name' => 'status',
|
102 |
+
'type' => 'select',
|
103 |
+
'class' => 'required-entry',
|
104 |
+
'label' => Mage::helper('colorswatch')->__('Status'),
|
105 |
+
'values' => $statuses
|
106 |
+
)
|
107 |
+
)
|
108 |
+
));
|
109 |
+
return $this;
|
110 |
+
}
|
111 |
+
|
112 |
+
public function getRowUrl($row)
|
113 |
+
{
|
114 |
+
return $this->getUrl('*/*/edit', array('id' => $row->getId()));
|
115 |
+
}
|
116 |
+
|
117 |
+
}
|
app/code/local/Intell/Colorswatch/Block/Colorswatch.php
ADDED
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Intell_Colorswatch_Block_Colorswatch extends Mage_Core_Block_Template
|
3 |
+
{
|
4 |
+
public function _prepareLayout()
|
5 |
+
{
|
6 |
+
return parent::_prepareLayout();
|
7 |
+
}
|
8 |
+
|
9 |
+
public function getColorswatch()
|
10 |
+
{
|
11 |
+
if (!$this->hasData('colorswatch')) {
|
12 |
+
$this->setData('colorswatch', Mage::registry('colorswatch'));
|
13 |
+
}
|
14 |
+
return $this->getData('colorswatch');
|
15 |
+
|
16 |
+
}
|
17 |
+
|
18 |
+
public function getSwatchImages(){
|
19 |
+
$data = $this->getRequest()->getParams();
|
20 |
+
// Collect options applicable to the configurable product
|
21 |
+
$product = Mage::getModel('catalog/product')->load($data['id']);
|
22 |
+
$productAttributeOptions = $product->getTypeInstance(true)->getConfigurableAttributesAsArray($product);
|
23 |
+
|
24 |
+
//get associated products
|
25 |
+
$associatedProductIds = $product->getTypeInstance(true)->getUsedProductIds($product);
|
26 |
+
$associatedProducts = array();
|
27 |
+
foreach($associatedProductIds as $associatedProductId){
|
28 |
+
$clildProduct = Mage::getModel('catalog/product')->load($associatedProductId);
|
29 |
+
$associatedProducts[$clildProduct->getColor()] = $clildProduct->getImageUrl();
|
30 |
+
|
31 |
+
}
|
32 |
+
|
33 |
+
$attributeOptions = array();
|
34 |
+
$swatch = "<ul>";
|
35 |
+
$imageHtml = '';
|
36 |
+
$mediaUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA);
|
37 |
+
//colorswatch model
|
38 |
+
$colorSwatchModel = Mage::getModel('colorswatch/colorswatch');
|
39 |
+
$collection = $colorSwatchModel->load();
|
40 |
+
foreach ($productAttributeOptions as $productAttribute) {
|
41 |
+
foreach ($productAttribute['values'] as $attribute) {
|
42 |
+
$attributeOptions[$productAttribute['label']][$attribute['value_index']] = $attribute['store_label'];
|
43 |
+
|
44 |
+
//swatch images
|
45 |
+
$data = $collection->getCollection()->addFieldToFilter('option_id', $attribute['value_index'])->getData();
|
46 |
+
$imageHtml = "<img alt='".$attribute['store_label']."' title='".$attribute['store_label']."' width='50' height='50' src='".$mediaUrl.$data[0]['filename']."'>";
|
47 |
+
$sekId = '\"attribute'.$productAttribute['attribute_id'].'\"';
|
48 |
+
$productImageUrl = '\"'.$associatedProducts[$attribute['value_index']].'\"';
|
49 |
+
//preparing li for swatches on product detail page
|
50 |
+
//$swatch .= "<li> <a href='javascript:void(0)' onclick='changesizedropdown(".$attribute['value_index'].",".$sekId.");'>".$imageHtml."</a></li>";
|
51 |
+
$swatch .= "<li> <a href='javascript:void(0)' onclick='changesizedropdown(".$attribute['value_index'].",".$sekId.",".$productImageUrl.");'>".$imageHtml."</a></li>";
|
52 |
+
}
|
53 |
+
}
|
54 |
+
$swatch .= "</ul>";
|
55 |
+
|
56 |
+
//print_r($product->getFinalPrice());
|
57 |
+
//print_r($productAttributeOptions);die;
|
58 |
+
|
59 |
+
return $swatch;
|
60 |
+
}
|
61 |
+
}
|
app/code/local/Intell/Colorswatch/Helper/Data.php
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Intell_Colorswatch_Helper_Data extends Mage_Core_Helper_Abstract
|
4 |
+
{
|
5 |
+
|
6 |
+
}
|
app/code/local/Intell/Colorswatch/Model/Colorswatch.php
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Intell_Colorswatch_Model_Colorswatch extends Mage_Core_Model_Abstract
|
4 |
+
{
|
5 |
+
public function _construct()
|
6 |
+
{
|
7 |
+
parent::_construct();
|
8 |
+
$this->_init('colorswatch/colorswatch');
|
9 |
+
}
|
10 |
+
}
|
app/code/local/Intell/Colorswatch/Model/Mysql4/Colorswatch.php
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Intell_Colorswatch_Model_Mysql4_Colorswatch extends Mage_Core_Model_Mysql4_Abstract
|
4 |
+
{
|
5 |
+
public function _construct()
|
6 |
+
{
|
7 |
+
// Note that the colorswatch_id refers to the key field in your database table.
|
8 |
+
$this->_init('colorswatch/colorswatch', 'colorswatch_id');
|
9 |
+
}
|
10 |
+
}
|
app/code/local/Intell/Colorswatch/Model/Mysql4/Colorswatch/Collection.php
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Intell_Colorswatch_Model_Mysql4_Colorswatch_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
|
4 |
+
{
|
5 |
+
public function _construct()
|
6 |
+
{
|
7 |
+
parent::_construct();
|
8 |
+
$this->_init('colorswatch/colorswatch');
|
9 |
+
}
|
10 |
+
}
|
app/code/local/Intell/Colorswatch/Model/Status.php
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Intell_Colorswatch_Model_Status extends Varien_Object
|
4 |
+
{
|
5 |
+
const STATUS_ENABLED = 1;
|
6 |
+
const STATUS_DISABLED = 2;
|
7 |
+
|
8 |
+
static public function getOptionArray()
|
9 |
+
{
|
10 |
+
return array(
|
11 |
+
self::STATUS_ENABLED => Mage::helper('colorswatch')->__('Enabled'),
|
12 |
+
self::STATUS_DISABLED => Mage::helper('colorswatch')->__('Disabled')
|
13 |
+
);
|
14 |
+
}
|
15 |
+
}
|
app/code/local/Intell/Colorswatch/controllers/Adminhtml/ColorswatchController.php
ADDED
@@ -0,0 +1,264 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Intell_Colorswatch_Adminhtml_ColorswatchController extends Mage_Adminhtml_Controller_action
|
4 |
+
{
|
5 |
+
|
6 |
+
protected function _initAction() {
|
7 |
+
$this->loadLayout()
|
8 |
+
->_setActiveMenu('colorswatch/items')
|
9 |
+
->_addBreadcrumb(Mage::helper('adminhtml')->__('Items Manager'), Mage::helper('adminhtml')->__('Item Manager'));
|
10 |
+
|
11 |
+
return $this;
|
12 |
+
}
|
13 |
+
|
14 |
+
public function indexAction() {
|
15 |
+
$this->_initAction()
|
16 |
+
->renderLayout();
|
17 |
+
}
|
18 |
+
|
19 |
+
public function installAction(){
|
20 |
+
//echo "Hello";die;
|
21 |
+
|
22 |
+
$attributeInfo = Mage::getResourceModel('eav/entity_attribute_collection')
|
23 |
+
->setCodeFilter('color')
|
24 |
+
->getFirstItem();
|
25 |
+
|
26 |
+
// Add the attribute code here.
|
27 |
+
$attribute = Mage::getModel('catalog/product')->getResource()->getAttribute("color");
|
28 |
+
|
29 |
+
// Checking if the attribute is either select or multiselect type.
|
30 |
+
if($attribute->usesSource()){
|
31 |
+
// Getting all the sources (options) and print as label-value pair
|
32 |
+
$options = $attribute->getSource()->getAllOptions(false);
|
33 |
+
}
|
34 |
+
|
35 |
+
foreach ($options as $item) {
|
36 |
+
$model = Mage::getModel('colorswatch/colorswatch');
|
37 |
+
$sel = $model->getCollection()->addFieldToFilter('option_id', $item['value'])->getData();
|
38 |
+
//print_r($sel);die;
|
39 |
+
if(empty($sel)){
|
40 |
+
$data = array("title" => $item['label'], "content" => "Logo of " . $item['label'], "option_id" => $item['value'], "filename" => "");
|
41 |
+
$model->setData($data);
|
42 |
+
try {
|
43 |
+
$model->save();
|
44 |
+
} catch (Exception $e) {
|
45 |
+
echo "<pre>";
|
46 |
+
print_r($e);
|
47 |
+
echo "</pre>";
|
48 |
+
}
|
49 |
+
}
|
50 |
+
|
51 |
+
$this->_redirect('*/*/');
|
52 |
+
|
53 |
+
}
|
54 |
+
|
55 |
+
}
|
56 |
+
|
57 |
+
public function editAction() {
|
58 |
+
$id = $this->getRequest()->getParam('id');
|
59 |
+
$model = Mage::getModel('colorswatch/colorswatch')->load($id);
|
60 |
+
|
61 |
+
if ($model->getId() || $id == 0) {
|
62 |
+
$data = Mage::getSingleton('adminhtml/session')->getFormData(true);
|
63 |
+
if (!empty($data)) {
|
64 |
+
$model->setData($data);
|
65 |
+
}
|
66 |
+
|
67 |
+
Mage::register('colorswatch_data', $model);
|
68 |
+
|
69 |
+
$this->loadLayout();
|
70 |
+
$this->_setActiveMenu('colorswatch/items');
|
71 |
+
|
72 |
+
$this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item Manager'), Mage::helper('adminhtml')->__('Item Manager'));
|
73 |
+
$this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item News'), Mage::helper('adminhtml')->__('Item News'));
|
74 |
+
|
75 |
+
$this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
|
76 |
+
|
77 |
+
$this->_addContent($this->getLayout()->createBlock('colorswatch/adminhtml_colorswatch_edit'))
|
78 |
+
->_addLeft($this->getLayout()->createBlock('colorswatch/adminhtml_colorswatch_edit_tabs'));
|
79 |
+
|
80 |
+
$this->renderLayout();
|
81 |
+
} else {
|
82 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('colorswatch')->__('Item does not exist'));
|
83 |
+
$this->_redirect('*/*/');
|
84 |
+
}
|
85 |
+
}
|
86 |
+
|
87 |
+
public function newAction() {
|
88 |
+
$this->_forward('edit');
|
89 |
+
}
|
90 |
+
|
91 |
+
public function saveAction() {
|
92 |
+
if ($data = $this->getRequest()->getPost()) {
|
93 |
+
|
94 |
+
if(isset($_FILES['filename']['name']) && $_FILES['filename']['name'] != '') {
|
95 |
+
try {
|
96 |
+
/* Starting upload */
|
97 |
+
$uploader = new Varien_File_Uploader('filename');
|
98 |
+
|
99 |
+
// Any extention would work
|
100 |
+
$uploader->setAllowedExtensions(array('jpg','jpeg','gif','png'));
|
101 |
+
$uploader->setAllowRenameFiles(false);
|
102 |
+
|
103 |
+
// Set the file upload mode
|
104 |
+
// false -> get the file directly in the specified folder
|
105 |
+
// true -> get the file in the product like folders
|
106 |
+
// (file.jpg will go in something like /media/f/i/file.jpg)
|
107 |
+
$uploader->setFilesDispersion(false);
|
108 |
+
|
109 |
+
// We set media as the upload dir
|
110 |
+
$path = Mage::getBaseDir('media') . DS ;
|
111 |
+
$uploader->save($path, str_replace(" ", "-", $_FILES['filename']['name']) );
|
112 |
+
|
113 |
+
} catch (Exception $e) {
|
114 |
+
|
115 |
+
}
|
116 |
+
|
117 |
+
//this way the name is saved in DB
|
118 |
+
$data['filename'] = str_replace(" ", "-", $_FILES['filename']['name']);
|
119 |
+
}
|
120 |
+
else{
|
121 |
+
//unset($data['filename']);
|
122 |
+
$data['filename'] = "";
|
123 |
+
}
|
124 |
+
|
125 |
+
|
126 |
+
$model = Mage::getModel('colorswatch/colorswatch');
|
127 |
+
|
128 |
+
//print_r($this->getRequest()->getParams());die;
|
129 |
+
|
130 |
+
$model->setData($data)
|
131 |
+
->setId($this->getRequest()->getParam('id'));
|
132 |
+
|
133 |
+
try {
|
134 |
+
if ($model->getCreatedTime == NULL || $model->getUpdateTime() == NULL) {
|
135 |
+
$model->setCreatedTime(now())
|
136 |
+
->setUpdateTime(now());
|
137 |
+
} else {
|
138 |
+
$model->setUpdateTime(now());
|
139 |
+
}
|
140 |
+
|
141 |
+
$model->save();
|
142 |
+
|
143 |
+
if($data['filename']['delete'] == 1){
|
144 |
+
$model->unsetData('filename');
|
145 |
+
}
|
146 |
+
|
147 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('colorswatch')->__('Item was successfully saved'));
|
148 |
+
Mage::getSingleton('adminhtml/session')->setFormData(false);
|
149 |
+
|
150 |
+
if ($this->getRequest()->getParam('back')) {
|
151 |
+
$this->_redirect('*/*/edit', array('id' => $model->getId()));
|
152 |
+
return;
|
153 |
+
}
|
154 |
+
$this->_redirect('*/*/');
|
155 |
+
return;
|
156 |
+
} catch (Exception $e) {
|
157 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
158 |
+
Mage::getSingleton('adminhtml/session')->setFormData($data);
|
159 |
+
$this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
|
160 |
+
return;
|
161 |
+
}
|
162 |
+
}
|
163 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('colorswatch')->__('Unable to find item to save'));
|
164 |
+
$this->_redirect('*/*/');
|
165 |
+
}
|
166 |
+
|
167 |
+
public function deleteAction() {
|
168 |
+
if( $this->getRequest()->getParam('id') > 0 ) {
|
169 |
+
try {
|
170 |
+
$model = Mage::getModel('colorswatch/colorswatch');
|
171 |
+
|
172 |
+
$model->setId($this->getRequest()->getParam('id'))
|
173 |
+
->delete();
|
174 |
+
|
175 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Item was successfully deleted'));
|
176 |
+
$this->_redirect('*/*/');
|
177 |
+
} catch (Exception $e) {
|
178 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
179 |
+
$this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
|
180 |
+
}
|
181 |
+
}
|
182 |
+
$this->_redirect('*/*/');
|
183 |
+
}
|
184 |
+
|
185 |
+
public function massDeleteAction() {
|
186 |
+
$colorswatchIds = $this->getRequest()->getParam('colorswatch');
|
187 |
+
if(!is_array($colorswatchIds)) {
|
188 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Please select item(s)'));
|
189 |
+
} else {
|
190 |
+
try {
|
191 |
+
foreach ($colorswatchIds as $colorswatchId) {
|
192 |
+
$colorswatch = Mage::getModel('colorswatch/colorswatch')->load($colorswatchId);
|
193 |
+
$colorswatch->delete();
|
194 |
+
}
|
195 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(
|
196 |
+
Mage::helper('adminhtml')->__(
|
197 |
+
'Total of %d record(s) were successfully deleted', count($colorswatchIds)
|
198 |
+
)
|
199 |
+
);
|
200 |
+
} catch (Exception $e) {
|
201 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
202 |
+
}
|
203 |
+
}
|
204 |
+
$this->_redirect('*/*/index');
|
205 |
+
}
|
206 |
+
|
207 |
+
public function massStatusAction()
|
208 |
+
{
|
209 |
+
$colorswatchIds = $this->getRequest()->getParam('colorswatch');
|
210 |
+
if(!is_array($colorswatchIds)) {
|
211 |
+
Mage::getSingleton('adminhtml/session')->addError($this->__('Please select item(s)'));
|
212 |
+
} else {
|
213 |
+
try {
|
214 |
+
foreach ($colorswatchIds as $colorswatchId) {
|
215 |
+
$colorswatch = Mage::getSingleton('colorswatch/colorswatch')
|
216 |
+
->load($colorswatchId)
|
217 |
+
->setStatus($this->getRequest()->getParam('status'))
|
218 |
+
->setIsMassupdate(true)
|
219 |
+
->save();
|
220 |
+
}
|
221 |
+
$this->_getSession()->addSuccess(
|
222 |
+
$this->__('Total of %d record(s) were successfully updated', count($colorswatchIds))
|
223 |
+
);
|
224 |
+
} catch (Exception $e) {
|
225 |
+
$this->_getSession()->addError($e->getMessage());
|
226 |
+
}
|
227 |
+
}
|
228 |
+
$this->_redirect('*/*/index');
|
229 |
+
}
|
230 |
+
|
231 |
+
public function exportCsvAction()
|
232 |
+
{
|
233 |
+
$fileName = 'colorswatch.csv';
|
234 |
+
$content = $this->getLayout()->createBlock('colorswatch/adminhtml_colorswatch_grid')
|
235 |
+
->getCsv();
|
236 |
+
|
237 |
+
$this->_sendUploadResponse($fileName, $content);
|
238 |
+
}
|
239 |
+
|
240 |
+
public function exportXmlAction()
|
241 |
+
{
|
242 |
+
$fileName = 'colorswatch.xml';
|
243 |
+
$content = $this->getLayout()->createBlock('colorswatch/adminhtml_colorswatch_grid')
|
244 |
+
->getXml();
|
245 |
+
|
246 |
+
$this->_sendUploadResponse($fileName, $content);
|
247 |
+
}
|
248 |
+
|
249 |
+
protected function _sendUploadResponse($fileName, $content, $contentType='application/octet-stream')
|
250 |
+
{
|
251 |
+
$response = $this->getResponse();
|
252 |
+
$response->setHeader('HTTP/1.1 200 OK','');
|
253 |
+
$response->setHeader('Pragma', 'public', true);
|
254 |
+
$response->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true);
|
255 |
+
$response->setHeader('Content-Disposition', 'attachment; filename='.$fileName);
|
256 |
+
$response->setHeader('Last-Modified', date('r'));
|
257 |
+
$response->setHeader('Accept-Ranges', 'bytes');
|
258 |
+
$response->setHeader('Content-Length', strlen($content));
|
259 |
+
$response->setHeader('Content-type', $contentType);
|
260 |
+
$response->setBody($content);
|
261 |
+
$response->sendResponse();
|
262 |
+
die;
|
263 |
+
}
|
264 |
+
}
|
app/code/local/Intell/Colorswatch/controllers/IndexController.php
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Intell_Colorswatch_IndexController extends Mage_Core_Controller_Front_Action
|
3 |
+
{
|
4 |
+
public function indexAction()
|
5 |
+
{
|
6 |
+
|
7 |
+
/*
|
8 |
+
* Load an object by id
|
9 |
+
* Request looking like:
|
10 |
+
* http://site.com/colorswatch?id=15
|
11 |
+
* or
|
12 |
+
* http://site.com/colorswatch/id/15
|
13 |
+
*/
|
14 |
+
/*
|
15 |
+
$colorswatch_id = $this->getRequest()->getParam('id');
|
16 |
+
|
17 |
+
if($colorswatch_id != null && $colorswatch_id != '') {
|
18 |
+
$colorswatch = Mage::getModel('colorswatch/colorswatch')->load($colorswatch_id)->getData();
|
19 |
+
} else {
|
20 |
+
$colorswatch = null;
|
21 |
+
}
|
22 |
+
*/
|
23 |
+
|
24 |
+
/*
|
25 |
+
* If no param we load a the last created item
|
26 |
+
*/
|
27 |
+
/*
|
28 |
+
if($colorswatch == null) {
|
29 |
+
$resource = Mage::getSingleton('core/resource');
|
30 |
+
$read= $resource->getConnection('core_read');
|
31 |
+
$colorswatchTable = $resource->getTableName('colorswatch');
|
32 |
+
|
33 |
+
$select = $read->select()
|
34 |
+
->from($colorswatchTable,array('colorswatch_id','title','content','status'))
|
35 |
+
->where('status',1)
|
36 |
+
->order('created_time DESC') ;
|
37 |
+
|
38 |
+
$colorswatch = $read->fetchRow($select);
|
39 |
+
}
|
40 |
+
Mage::register('colorswatch', $colorswatch);
|
41 |
+
*/
|
42 |
+
|
43 |
+
|
44 |
+
$this->loadLayout();
|
45 |
+
$this->renderLayout();
|
46 |
+
}
|
47 |
+
}
|
app/code/local/Intell/Colorswatch/etc/XX-adminhtml.xml
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<config>
|
3 |
+
<acl>
|
4 |
+
<resources>
|
5 |
+
<all>
|
6 |
+
<title>Allow Everything</title>
|
7 |
+
</all>
|
8 |
+
<admin>
|
9 |
+
<children>
|
10 |
+
<Intell_Colorswatch>
|
11 |
+
<title>Colorswatch Module</title>
|
12 |
+
<sort_order>10</sort_order>
|
13 |
+
</Intell_Colorswatch>
|
14 |
+
<system>
|
15 |
+
<children>
|
16 |
+
<config>
|
17 |
+
<children>
|
18 |
+
<small>
|
19 |
+
<title>General Settings</title>
|
20 |
+
</small>
|
21 |
+
</children>
|
22 |
+
</config>
|
23 |
+
</children>
|
24 |
+
</system>
|
25 |
+
</children>
|
26 |
+
</admin>
|
27 |
+
</resources>
|
28 |
+
</acl>
|
29 |
+
</config>
|
app/code/local/Intell/Colorswatch/etc/config.xml
ADDED
@@ -0,0 +1,139 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* @category Intell
|
5 |
+
* @package Intell_Colorswatch
|
6 |
+
* @author ModuleCreator
|
7 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
8 |
+
*/
|
9 |
+
-->
|
10 |
+
<config>
|
11 |
+
<modules>
|
12 |
+
<Intell_Colorswatch>
|
13 |
+
<version>0.1.0</version>
|
14 |
+
</Intell_Colorswatch>
|
15 |
+
</modules>
|
16 |
+
<frontend>
|
17 |
+
<routers>
|
18 |
+
<colorswatch>
|
19 |
+
<use>standard</use>
|
20 |
+
<args>
|
21 |
+
<module>Intell_Colorswatch</module>
|
22 |
+
<frontName>colorswatch</frontName>
|
23 |
+
</args>
|
24 |
+
</colorswatch>
|
25 |
+
</routers>
|
26 |
+
<layout>
|
27 |
+
<updates>
|
28 |
+
<colorswatch>
|
29 |
+
<file>colorswatch.xml</file>
|
30 |
+
</colorswatch>
|
31 |
+
</updates>
|
32 |
+
</layout>
|
33 |
+
</frontend>
|
34 |
+
<admin>
|
35 |
+
<routers>
|
36 |
+
<colorswatch>
|
37 |
+
<use>admin</use>
|
38 |
+
<args>
|
39 |
+
<module>Intell_Colorswatch</module>
|
40 |
+
<frontName>colorswatch</frontName>
|
41 |
+
</args>
|
42 |
+
</colorswatch>
|
43 |
+
</routers>
|
44 |
+
</admin>
|
45 |
+
<adminhtml>
|
46 |
+
<menu>
|
47 |
+
<colorswatch module="colorswatch">
|
48 |
+
<title>Colorswatch</title>
|
49 |
+
<sort_order>71</sort_order>
|
50 |
+
<children>
|
51 |
+
<items module="colorswatch">
|
52 |
+
<title>Manage Items</title>
|
53 |
+
<sort_order>0</sort_order>
|
54 |
+
<action>colorswatch/adminhtml_colorswatch</action>
|
55 |
+
</items>
|
56 |
+
</children>
|
57 |
+
</colorswatch>
|
58 |
+
</menu>
|
59 |
+
<acl>
|
60 |
+
<resources>
|
61 |
+
<all>
|
62 |
+
<title>Allow Everything</title>
|
63 |
+
</all>
|
64 |
+
<admin>
|
65 |
+
<children>
|
66 |
+
<Intell_Colorswatch>
|
67 |
+
<title>Colorswatch Module</title>
|
68 |
+
<sort_order>10</sort_order>
|
69 |
+
</Intell_Colorswatch>
|
70 |
+
<system>
|
71 |
+
<children>
|
72 |
+
<config>
|
73 |
+
<children>
|
74 |
+
<color>
|
75 |
+
<title>Settings</title>
|
76 |
+
</color>
|
77 |
+
</children>
|
78 |
+
</config>
|
79 |
+
</children>
|
80 |
+
</system>
|
81 |
+
</children>
|
82 |
+
</admin>
|
83 |
+
</resources>
|
84 |
+
</acl>
|
85 |
+
<layout>
|
86 |
+
<updates>
|
87 |
+
<colorswatch>
|
88 |
+
<file>colorswatch.xml</file>
|
89 |
+
</colorswatch>
|
90 |
+
</updates>
|
91 |
+
</layout>
|
92 |
+
</adminhtml>
|
93 |
+
<global>
|
94 |
+
<models>
|
95 |
+
<colorswatch>
|
96 |
+
<class>Intell_Colorswatch_Model</class>
|
97 |
+
<resourceModel>colorswatch_mysql4</resourceModel>
|
98 |
+
</colorswatch>
|
99 |
+
<colorswatch_mysql4>
|
100 |
+
<class>Intell_Colorswatch_Model_Mysql4</class>
|
101 |
+
<entities>
|
102 |
+
<colorswatch>
|
103 |
+
<table>colorswatch</table>
|
104 |
+
</colorswatch>
|
105 |
+
</entities>
|
106 |
+
</colorswatch_mysql4>
|
107 |
+
</models>
|
108 |
+
<resources>
|
109 |
+
<colorswatch_setup>
|
110 |
+
<setup>
|
111 |
+
<module>Intell_Colorswatch</module>
|
112 |
+
</setup>
|
113 |
+
<connection>
|
114 |
+
<use>core_setup</use>
|
115 |
+
</connection>
|
116 |
+
</colorswatch_setup>
|
117 |
+
<colorswatch_write>
|
118 |
+
<connection>
|
119 |
+
<use>core_write</use>
|
120 |
+
</connection>
|
121 |
+
</colorswatch_write>
|
122 |
+
<colorswatch_read>
|
123 |
+
<connection>
|
124 |
+
<use>core_read</use>
|
125 |
+
</connection>
|
126 |
+
</colorswatch_read>
|
127 |
+
</resources>
|
128 |
+
<blocks>
|
129 |
+
<colorswatch>
|
130 |
+
<class>Intell_Colorswatch_Block</class>
|
131 |
+
</colorswatch>
|
132 |
+
</blocks>
|
133 |
+
<helpers>
|
134 |
+
<colorswatch>
|
135 |
+
<class>Intell_Colorswatch_Helper</class>
|
136 |
+
</colorswatch>
|
137 |
+
</helpers>
|
138 |
+
</global>
|
139 |
+
</config>
|
app/code/local/Intell/Colorswatch/etc/system.xml
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<sections>
|
4 |
+
<color translate="label">
|
5 |
+
<label>Intell Color Swatcher</label>
|
6 |
+
<tab>general</tab>
|
7 |
+
<frontend_type>text</frontend_type>
|
8 |
+
<sort_order>1000</sort_order>
|
9 |
+
<show_in_default>1</show_in_default>
|
10 |
+
<show_in_website>1</show_in_website>
|
11 |
+
<show_in_store>1</show_in_store>
|
12 |
+
<groups>
|
13 |
+
<!-- New groups go here -->
|
14 |
+
<sample translate="label">
|
15 |
+
<label>Settings</label>
|
16 |
+
<frontend_type>text</frontend_type>
|
17 |
+
<sort_order>100</sort_order>
|
18 |
+
<show_in_default>1</show_in_default>
|
19 |
+
<show_in_website>1</show_in_website>
|
20 |
+
<show_in_store>1</show_in_store>
|
21 |
+
<fields>
|
22 |
+
<!-- New fields go here -->
|
23 |
+
<ENABLED translate="label comment">
|
24 |
+
<label>Enabled</label>
|
25 |
+
<!--<comment><![CDATA[This text appears just beneath the field with a small arrow.<span class="notice">It can contain HTML formatting too!</span>]]></comment>-->
|
26 |
+
<frontend_type>select</frontend_type>
|
27 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
28 |
+
<sort_order>10</sort_order>
|
29 |
+
<show_in_default>1</show_in_default>
|
30 |
+
<show_in_website>1</show_in_website>
|
31 |
+
<show_in_store>1</show_in_store>
|
32 |
+
</ENABLED>
|
33 |
+
</fields>
|
34 |
+
</sample>
|
35 |
+
</groups>
|
36 |
+
</color>
|
37 |
+
</sections>
|
38 |
+
</config>
|
app/code/local/Intell/Colorswatch/sql/colorswatch_setup/mysql4-install-0.1.0.php
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
$installer = $this;
|
4 |
+
|
5 |
+
$installer->startSetup();
|
6 |
+
|
7 |
+
$installer->run("
|
8 |
+
|
9 |
+
-- DROP TABLE IF EXISTS {$this->getTable('colorswatch')};
|
10 |
+
CREATE TABLE {$this->getTable('colorswatch')} (
|
11 |
+
`colorswatch_id` int(11) unsigned NOT NULL auto_increment,
|
12 |
+
`title` varchar(255) NOT NULL default '',
|
13 |
+
`filename` varchar(255) NOT NULL default '',
|
14 |
+
`option_id` varchar(255) NOT NULL default '',
|
15 |
+
`content` text NOT NULL default '',
|
16 |
+
`status` smallint(6) NOT NULL default '0',
|
17 |
+
`created_time` datetime NULL,
|
18 |
+
`update_time` datetime NULL,
|
19 |
+
PRIMARY KEY (`colorswatch_id`)
|
20 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
21 |
+
|
22 |
+
");
|
23 |
+
|
24 |
+
$installer->endSetup();
|
app/design/adminhtml/default/default/layout/colorswatch.xml
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<layout version="0.1.0">
|
3 |
+
<colorswatch_adminhtml_colorswatch_index>
|
4 |
+
<reference name="content">
|
5 |
+
<block type="colorswatch/adminhtml_colorswatch" name="colorswatch" />
|
6 |
+
</reference>
|
7 |
+
</colorswatch_adminhtml_colorswatch_index>
|
8 |
+
</layout>
|
app/design/frontend/default/default/layout/colorswatch.xml
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<layout version="0.1.0">
|
3 |
+
<default>
|
4 |
+
</default>
|
5 |
+
<colorswatch_index_index>
|
6 |
+
<reference name="content">
|
7 |
+
<block type="colorswatch/colorswatch" name="colorswatch" template="colorswatch/colorswatch.phtml" />
|
8 |
+
</reference>
|
9 |
+
</colorswatch_index_index>
|
10 |
+
|
11 |
+
<catalog_product_view translate="label">
|
12 |
+
<reference name="product.info">
|
13 |
+
<action method="setTemplate"><template>colorswatch/view.phtml</template></action>
|
14 |
+
</reference>
|
15 |
+
</catalog_product_view>
|
16 |
+
</layout>
|
app/design/frontend/default/default/template/colorswatch/colorswatch.phtml
ADDED
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<h4><?php echo $this->__('Module List') ?></h4>
|
2 |
+
<?php
|
3 |
+
|
4 |
+
/*
|
5 |
+
This shows how to load specific fields from a record in the database.
|
6 |
+
1) Note the load(15), this corresponds to saying "select * from table where table_id = 15"
|
7 |
+
2) You can then just use the get(fieldname) to pull specific data from the table.
|
8 |
+
3) If you have a field named news_id, then it becomes getNewsId, etc.
|
9 |
+
*/
|
10 |
+
/*
|
11 |
+
$news = Mage::getModel('colorswatch/colorswatch')->load(15);
|
12 |
+
echo $news->getNewsId();
|
13 |
+
echo $news->getTitle();
|
14 |
+
echo $news->getContent();
|
15 |
+
echo $news->getStatus();
|
16 |
+
*/
|
17 |
+
|
18 |
+
/*
|
19 |
+
This shows an alternate way of loading datas from a record using the database the "Magento Way" (using blocks and controller).
|
20 |
+
Uncomment blocks in /app/code/local/Namespace/Module/controllers/IndexController.php if you want to use it.
|
21 |
+
|
22 |
+
*/
|
23 |
+
/*
|
24 |
+
$object = $this->getColorswatch();
|
25 |
+
echo 'id: '.$object['test_id'].'<br/>';
|
26 |
+
echo 'title: '.$object['title'].'<br/>';
|
27 |
+
echo 'content: '.$object['content'].'<br/>';
|
28 |
+
echo 'status: '.$object['status'].'<br/>';
|
29 |
+
*/
|
30 |
+
|
31 |
+
|
32 |
+
/*
|
33 |
+
This shows how to load multiple rows in a collection and save a change to them.
|
34 |
+
1) The setPageSize function will load only 5 records per page and you can set the current Page with the setCurPage function.
|
35 |
+
2) The $collection->walk('save') allows you to save everything in the collection after all changes have been made.
|
36 |
+
*/
|
37 |
+
/*
|
38 |
+
$i = 0;
|
39 |
+
|
40 |
+
$collection = Mage::getModel('colorswatch/colorswatch')->getCollection();
|
41 |
+
$collection->setPageSize(5);
|
42 |
+
$collection->setCurPage(2);
|
43 |
+
$size = $collection->getSize();
|
44 |
+
$cnt = count($collection);
|
45 |
+
foreach ($collection as $item) {
|
46 |
+
$i = $i+1;
|
47 |
+
$item->setTitle($i);
|
48 |
+
echo $item->getTitle();
|
49 |
+
}
|
50 |
+
|
51 |
+
$collection->walk('save');
|
52 |
+
*/
|
53 |
+
|
54 |
+
/*
|
55 |
+
This shows how to load a single record and save a change.
|
56 |
+
1) Note the setTitle, this corresponds to the table field name, title, and then you pass it the text to change.
|
57 |
+
2) Call the save() function only on a single record.
|
58 |
+
*/
|
59 |
+
/*
|
60 |
+
$object = Mage::getModel('colorswatch/colorswatch')->load(1);
|
61 |
+
$object->setTitle('This is a changed title');
|
62 |
+
$object->save();
|
63 |
+
*/
|
64 |
+
|
65 |
+
?>
|
app/design/frontend/default/default/template/colorswatch/view.phtml
ADDED
@@ -0,0 +1,218 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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@magentocommerce.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.magentocommerce.com for more information.
|
20 |
+
*
|
21 |
+
* @category design
|
22 |
+
* @package base_default
|
23 |
+
* @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
|
24 |
+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
25 |
+
*/
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Product view template
|
29 |
+
*
|
30 |
+
* @see Mage_Catalog_Block_Product_View
|
31 |
+
* @see Mage_Review_Block_Product_View
|
32 |
+
*/
|
33 |
+
?>
|
34 |
+
<?php $_helper = $this->helper('catalog/output'); ?>
|
35 |
+
<?php $_product = $this->getProduct(); ?>
|
36 |
+
<script type="text/javascript">
|
37 |
+
var optionsPrice = new Product.OptionsPrice(<?php echo $this->getJsonConfig() ?>);
|
38 |
+
</script>
|
39 |
+
<div id="messages_product_view"><?php echo $this->getMessagesBlock()->getGroupedHtml() ?></div>
|
40 |
+
<div class="product-view">
|
41 |
+
<div class="product-essential">
|
42 |
+
<form action="<?php echo $this->getSubmitUrl($_product) ?>" method="post" id="product_addtocart_form"<?php if($_product->getOptions()): ?> enctype="multipart/form-data"<?php endif; ?>>
|
43 |
+
<div class="no-display">
|
44 |
+
<input type="hidden" name="product" value="<?php echo $_product->getId() ?>" />
|
45 |
+
<input type="hidden" name="related_product" id="related-products-field" value="" />
|
46 |
+
</div>
|
47 |
+
|
48 |
+
<div class="product-shop">
|
49 |
+
<div class="product-name">
|
50 |
+
<h1><?php echo $_helper->productAttribute($_product, $_product->getName(), 'name') ?></h1>
|
51 |
+
</div>
|
52 |
+
|
53 |
+
<?php if ($this->canEmailToFriend()): ?>
|
54 |
+
<p class="email-friend"><a href="<?php echo $this->helper('catalog/product')->getEmailToFriendUrl($_product) ?>"><?php echo $this->__('Email to a Friend') ?></a></p>
|
55 |
+
<?php endif; ?>
|
56 |
+
|
57 |
+
<?php echo $this->getReviewsSummaryHtml($_product, false, true)?>
|
58 |
+
<?php echo $this->getChildHtml('alert_urls') ?>
|
59 |
+
<?php echo $this->getChildHtml('product_type_data') ?>
|
60 |
+
<?php echo $this->getTierPriceHtml() ?>
|
61 |
+
<?php echo $this->getChildHtml('extrahint') ?>
|
62 |
+
|
63 |
+
<?php if (!$this->hasOptions()):?>
|
64 |
+
<div class="add-to-box">
|
65 |
+
<?php if($_product->isSaleable()): ?>
|
66 |
+
<?php echo $this->getChildHtml('addtocart') ?>
|
67 |
+
<?php if( $this->helper('wishlist')->isAllow() || $_compareUrl=$this->helper('catalog/product_compare')->getAddUrl($_product)): ?>
|
68 |
+
<span class="or"><?php echo $this->__('OR') ?></span>
|
69 |
+
<?php endif; ?>
|
70 |
+
<?php endif; ?>
|
71 |
+
<?php echo $this->getChildHtml('addto') ?>
|
72 |
+
</div>
|
73 |
+
<?php echo $this->getChildHtml('extra_buttons') ?>
|
74 |
+
<?php elseif (!$_product->isSaleable()): ?>
|
75 |
+
<div class="add-to-box">
|
76 |
+
<?php echo $this->getChildHtml('addto') ?>
|
77 |
+
</div>
|
78 |
+
<?php endif; ?>
|
79 |
+
|
80 |
+
<?php if ($_product->getShortDescription()):?>
|
81 |
+
<div class="short-description">
|
82 |
+
<h2><?php echo $this->__('Quick Overview') ?></h2>
|
83 |
+
<div class="std"><?php echo $_helper->productAttribute($_product, nl2br($_product->getShortDescription()), 'short_description') ?></div>
|
84 |
+
</div>
|
85 |
+
<?php endif;?>
|
86 |
+
|
87 |
+
<?php echo $this->getChildHtml('other');?>
|
88 |
+
|
89 |
+
<?php if ($_product->isSaleable() && $this->hasOptions()):?>
|
90 |
+
<?php echo $this->getChildChildHtml('container1', '', true, true) ?>
|
91 |
+
<?php //$colorSwatchBlock = $this->getLayout()->createBlock('colorswatch/colorswatch'); ?>
|
92 |
+
<?php //echo $colorSwatchBlock->getSwatchImages(); ?>
|
93 |
+
<?php endif;?>
|
94 |
+
|
95 |
+
</div>
|
96 |
+
|
97 |
+
<div class="product-img-box">
|
98 |
+
<?php echo $this->getChildHtml('media') ?>
|
99 |
+
</div>
|
100 |
+
|
101 |
+
<div class="clearer"></div>
|
102 |
+
<?php if ($_product->isSaleable() && $this->hasOptions()):?>
|
103 |
+
<?php echo $this->getChildChildHtml('container2', '', true, true) ?>
|
104 |
+
<?php endif;?>
|
105 |
+
</form>
|
106 |
+
<script type="text/javascript">
|
107 |
+
//<![CDATA[
|
108 |
+
var productAddToCartForm = new VarienForm('product_addtocart_form');
|
109 |
+
productAddToCartForm.submit = function(button, url) {
|
110 |
+
if (this.validator.validate()) {
|
111 |
+
var form = this.form;
|
112 |
+
var oldUrl = form.action;
|
113 |
+
|
114 |
+
if (url) {
|
115 |
+
form.action = url;
|
116 |
+
}
|
117 |
+
var e = null;
|
118 |
+
try {
|
119 |
+
this.form.submit();
|
120 |
+
} catch (e) {
|
121 |
+
}
|
122 |
+
this.form.action = oldUrl;
|
123 |
+
if (e) {
|
124 |
+
throw e;
|
125 |
+
}
|
126 |
+
|
127 |
+
if (button && button != 'undefined') {
|
128 |
+
button.disabled = true;
|
129 |
+
}
|
130 |
+
}
|
131 |
+
}.bind(productAddToCartForm);
|
132 |
+
|
133 |
+
productAddToCartForm.submitLight = function(button, url){
|
134 |
+
if(this.validator) {
|
135 |
+
var nv = Validation.methods;
|
136 |
+
delete Validation.methods['required-entry'];
|
137 |
+
delete Validation.methods['validate-one-required'];
|
138 |
+
delete Validation.methods['validate-one-required-by-name'];
|
139 |
+
// Remove custom datetime validators
|
140 |
+
for (var methodName in Validation.methods) {
|
141 |
+
if (methodName.match(/^validate-datetime-.*/i)) {
|
142 |
+
delete Validation.methods[methodName];
|
143 |
+
}
|
144 |
+
}
|
145 |
+
|
146 |
+
if (this.validator.validate()) {
|
147 |
+
if (url) {
|
148 |
+
this.form.action = url;
|
149 |
+
}
|
150 |
+
this.form.submit();
|
151 |
+
}
|
152 |
+
Object.extend(Validation.methods, nv);
|
153 |
+
}
|
154 |
+
}.bind(productAddToCartForm);
|
155 |
+
//]]>
|
156 |
+
</script>
|
157 |
+
</div>
|
158 |
+
|
159 |
+
<div class="product-collateral">
|
160 |
+
<?php foreach ($this->getChildGroup('detailed_info', 'getChildHtml') as $alias => $html):?>
|
161 |
+
<div class="box-collateral <?php echo "box-{$alias}"?>">
|
162 |
+
<?php if ($title = $this->getChildData($alias, 'title')):?>
|
163 |
+
<h2><?php echo $this->escapeHtml($title); ?></h2>
|
164 |
+
<?php endif;?>
|
165 |
+
<?php echo $html; ?>
|
166 |
+
</div>
|
167 |
+
<?php endforeach;?>
|
168 |
+
<?php echo $this->getChildHtml('upsell_products') ?>
|
169 |
+
<?php echo $this->getChildHtml('product_additional_data') ?>
|
170 |
+
</div>
|
171 |
+
</div>
|
172 |
+
|
173 |
+
<?php //color swatch ?>
|
174 |
+
|
175 |
+
<?php if(Mage::getStoreConfig('color/sample/ENABLED')): ?>
|
176 |
+
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
|
177 |
+
<style style="type/css">
|
178 |
+
.size{ height:auto; margin:15px 0px;}
|
179 |
+
.size ul {margin:0px; padding:0px; list-style-type:none; width:180px; display:block;}
|
180 |
+
.size ul li { margin:0px 3px 5px 3px; padding:0px; float:left;}
|
181 |
+
|
182 |
+
</style>
|
183 |
+
|
184 |
+
<div id="sizeswatch"></div>
|
185 |
+
<script type="text/javascript">
|
186 |
+
var jQuery = jQuery.noConflict();
|
187 |
+
function changesizedropdown(size,elId, imageSrc){
|
188 |
+
var option = size;
|
189 |
+
var select = document.getElementById(elId);
|
190 |
+
//var select = jQuery('.selectsuper-attribute-select');
|
191 |
+
var opt, o = 0;
|
192 |
+
while (opt = select[o++]){
|
193 |
+
if (opt.value == option){ select.selectedIndex = o - 1; }
|
194 |
+
}
|
195 |
+
spConfig.reloadPrice();
|
196 |
+
document.getElementById('image').src = imageSrc;
|
197 |
+
}
|
198 |
+
jQuery(document).ready(function () {
|
199 |
+
var swatch = '';
|
200 |
+
var selectkId = '';
|
201 |
+
var swatchId = '';
|
202 |
+
var image = '';
|
203 |
+
|
204 |
+
jQuery('#product-options-wrapper .input-box:eq(0) option').each(function() {
|
205 |
+
selectkId = jQuery(this).parent().attr('id');
|
206 |
+
});
|
207 |
+
<?php $colorSwatchBlock = $this->getLayout()->createBlock('colorswatch/colorswatch'); ?>
|
208 |
+
var html = "<?php echo $colorSwatchBlock->getSwatchImages(); ?>";
|
209 |
+
var sizeswatchhtml = "<dd class='colorswatch' ><div class='size'><div style='float: left; margin: 6px 5px 0px 0px;'></div><div style='float: left; margin: 0pt 7px 0px 13px;'>"+html+"</div></div></dd>";
|
210 |
+
jQuery('#'+selectkId).hide();
|
211 |
+
jQuery('#'+selectkId).parent().parent().parent().append(sizeswatchhtml);
|
212 |
+
|
213 |
+
//document.getElementById('sizeswatch').innerHTML = sizeswatchhtml;
|
214 |
+
|
215 |
+
});
|
216 |
+
|
217 |
+
</script>
|
218 |
+
<?php endif; ?>
|
app/etc/modules/Intell_Colorswatch.xml
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* @category Intell
|
5 |
+
* @package Intell_Colorswatch
|
6 |
+
* @author ModuleCreator
|
7 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
8 |
+
*/
|
9 |
+
-->
|
10 |
+
<config>
|
11 |
+
<modules>
|
12 |
+
<Intell_Colorswatch>
|
13 |
+
<active>true</active>
|
14 |
+
<codePool>local</codePool>
|
15 |
+
</Intell_Colorswatch>
|
16 |
+
</modules>
|
17 |
+
</config>
|
package.xml
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>intell_colorswatch</name>
|
4 |
+
<version>1.0.0.1</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license>OSL v3.0</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>intell_colorswatch</summary>
|
10 |
+
<description>intell_colorswatch</description>
|
11 |
+
<notes>New</notes>
|
12 |
+
<authors><author><name>Amatya</name><user>intelligrape</user><email>shahid@intelligrape.com</email></author></authors>
|
13 |
+
<date>2012-10-27</date>
|
14 |
+
<time>06:23:31</time>
|
15 |
+
<contents><target name="magelocal"><dir name="Intell"><dir name="Colorswatch"><dir name="Block"><dir name="Adminhtml"><dir name="Colorswatch"><dir name="Edit"><file name="Form.php" hash="3f0f489b5a42b2f3756b69ac97d707e0"/><dir name="Tab"><file name="Form.php" hash="8550a2ef316dac4b292c2073d5626ef0"/></dir><file name="Tabs.php" hash="a5065edc7f21a0d5872582d6b2315c6f"/></dir><file name="Edit.php" hash="a3a739ff457869652b69f51ec88c8dcc"/><file name="Grid.php" hash="f2690ad6626771a759f60f759ab5985f"/></dir><file name="Colorswatch.php" hash="6d21c0f127752901381399db379025c4"/></dir><file name="Colorswatch.php" hash="77d72ac26dd7527ce2ee8af918c4d595"/></dir><dir name="Helper"><file name="Data.php" hash="67a8498de9a61502b878dae0e35572ef"/></dir><dir name="Model"><file name="Colorswatch.php" hash="58e10e302a879194f94c6b787596e23d"/><dir name="Mysql4"><dir name="Colorswatch"><file name="Collection.php" hash="989993cf07ffc8498be6e4926395e240"/></dir><file name="Colorswatch.php" hash="abd8a3f349000a99d2cbce94ff456fdb"/></dir><file name="Status.php" hash="8e2f254045f6d1d015f5ec5c06c97d8a"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="ColorswatchController.php" hash="c355eb27b5b667e336d8f7cdfeb939f5"/></dir><file name="IndexController.php" hash="8fada94196fb5b042a67677ac018ae31"/></dir><dir name="etc"><file name="XX-adminhtml.xml" hash="7c80c15e232958f5feae8c50128e7214"/><file name="config.xml" hash="ca29b68f64ff5bbe049f5f2be3c70d42"/><file name="system.xml" hash="458afc03ca31e33ced90d5e42cacc2c1"/></dir><dir name="sql"><dir name="colorswatch_setup"><file name="mysql4-install-0.1.0.php" hash="c3ce8356cf8a37acce8d07535ebe1895"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Intell_Colorswatch.xml" hash="c2b4871fb366d29f159f9a64b2213b32"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="colorswatch.xml" hash="8967607f63b8f92125619228f7e2f51e"/></dir></dir></dir></dir><dir name="frontend"><dir name="default"><dir name="default"><dir name="layout"><file name="colorswatch.xml" hash="981e2a949b10e08c1212f54d788efa33"/></dir><dir name="template"><dir name="colorswatch"><file name="colorswatch.phtml" hash="96b1be2bae3085ec5b96176558314416"/><file name="view.phtml" hash="c90943a0710c25eb86de6d92cb565055"/></dir></dir></dir></dir></dir></target><target name="mageskin"><dir name="frontend"><dir name="default"><dir name="default"><dir name="colorswatch"><dir name="js"><file name="featuredimagezoomer.js" hash="22bae1b3e7a63b43e142d049b3f68ea4"/></dir></dir></dir></dir></dir></target></contents>
|
16 |
+
<compatible/>
|
17 |
+
<dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
|
18 |
+
</package>
|
skin/frontend/default/default/colorswatch/js/featuredimagezoomer.js
ADDED
@@ -0,0 +1,233 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/*Featured Image Zoomer (May 8th, 2010)
|
2 |
+
* This notice must stay intact for usage
|
3 |
+
* Author: Dynamic Drive at http://www.dynamicdrive.com/
|
4 |
+
* Visit http://www.dynamicdrive.com/ for full source code
|
5 |
+
*/
|
6 |
+
|
7 |
+
// Feb 21st, 2011: Script updated to v1.5, which now includes new feature by jscheuer1 (http://www.dynamicdrive.com/forums/member.php?u=2033) to show optional "magnifying lens" while over thumbnail image.
|
8 |
+
// March 1st, 2011: Script updated to v1.51. Minor improvements to inner workings of script.
|
9 |
+
// July 9th, 12': Script updated to v1.5.1, which fixes mouse wheel issue with script when used with a more recent version of jQuery.
|
10 |
+
|
11 |
+
jQuery.noConflict()
|
12 |
+
|
13 |
+
jQuery('head').append('<style type="text/css">.featuredimagezoomerhidden {visibility: hidden!important;}</style>');
|
14 |
+
|
15 |
+
var featuredimagezoomer={
|
16 |
+
loadinggif: 'spinningred.gif', //full path or URL to "loading" gif
|
17 |
+
magnifycursor: 'crosshair', //Value for CSS's 'cursor' attribute, added to original image
|
18 |
+
|
19 |
+
/////NO NEED TO EDIT BEYOND HERE////////////////
|
20 |
+
dsetting: { //default settings
|
21 |
+
magnifierpos: 'right',
|
22 |
+
magnifiersize:[200, 200],
|
23 |
+
cursorshadecolor: '#fff',
|
24 |
+
cursorshadeopacity: 0.3,
|
25 |
+
cursorshadeborder: '1px solid black',
|
26 |
+
cursorshade: false,
|
27 |
+
leftoffset: 15, //offsets here are used (added to) the width of the magnifyarea when
|
28 |
+
rightoffset: 10 //calculating space requirements and to position it visa vis any drop shadow
|
29 |
+
},
|
30 |
+
isie: (function(){/*@cc_on @*//*@if(@_jscript_version >= 5)return true;@end @*/return false;})(), //is this IE?
|
31 |
+
|
32 |
+
showimage: function($, $tracker, $mag, showstatus){
|
33 |
+
var specs=$tracker.data('specs'), d=specs.magpos, fiz=this;
|
34 |
+
var coords=$tracker.data('specs').coords //get coords of tracker (from upper corner of document)
|
35 |
+
specs.windimensions={w:$(window).width(), h:$(window).height()}; //remember window dimensions
|
36 |
+
var magcoords={} //object to store coords magnifier DIV should move to
|
37 |
+
magcoords.left = coords.left + (d === 'left'? -specs.magsize.w - specs.lo : $tracker.width() + specs.ro);
|
38 |
+
//switch sides for magnifiers that don't have enough room to display on the right if there's room on the left:
|
39 |
+
if(d!=='left' && magcoords.left + specs.magsize.w + specs.lo >= specs.windimensions.w && coords.left - specs.magsize.w >= specs.lo){
|
40 |
+
magcoords.left = coords.left - specs.magsize.w - specs.lo;
|
41 |
+
} else if(d==='left' && magcoords.left < specs.ro) { //if there's no room on the left, move to the right
|
42 |
+
magcoords.left = coords.left + $tracker.width() + specs.ro;
|
43 |
+
}
|
44 |
+
$mag.css({left: magcoords.left, top:coords.top}).show(); //position magnifier DIV on page
|
45 |
+
//specs.$statusdiv.html('Current Zoom: '+specs.curpower+'<div style="font-size:80%">Use Mouse Wheel to Zoom In/Out</div>');
|
46 |
+
specs.$statusdiv.html('<div style="font-size:80%">Use Mouse Wheel to Zoom In/Out</div>');
|
47 |
+
if (showstatus) //show status DIV? (only when a range of zoom is defined)
|
48 |
+
fiz.showstatusdiv(specs, 400, 2000);
|
49 |
+
},
|
50 |
+
|
51 |
+
hideimage: function($tracker, $mag, showstatus){
|
52 |
+
var specs=$tracker.data('specs');
|
53 |
+
$mag.hide();
|
54 |
+
if (showstatus)
|
55 |
+
this.hidestatusdiv(specs);
|
56 |
+
},
|
57 |
+
|
58 |
+
showstatusdiv: function(specs, fadedur, showdur){
|
59 |
+
clearTimeout(specs.statustimer)
|
60 |
+
specs.$statusdiv.fadeIn(fadedur) //show status div
|
61 |
+
specs.statustimer=setTimeout(function(){featuredimagezoomer.hidestatusdiv(specs)}, showdur) //hide status div after delay
|
62 |
+
},
|
63 |
+
|
64 |
+
hidestatusdiv: function(specs){
|
65 |
+
specs.$statusdiv.stop(true, true).hide()
|
66 |
+
},
|
67 |
+
|
68 |
+
getboundary: function(b, val, specs){ //function to set x and y boundaries magnified image can move to (moved outside moveimage for efficiency)
|
69 |
+
if (b=="left"){
|
70 |
+
var rb=-specs.imagesize.w*specs.curpower+specs.magsize.w
|
71 |
+
return (val>0)? 0 : (val<rb)? rb : val
|
72 |
+
}
|
73 |
+
else{
|
74 |
+
var tb=-specs.imagesize.h*specs.curpower+specs.magsize.h
|
75 |
+
return (val>0)? 0 : (val<tb)? tb : val
|
76 |
+
}
|
77 |
+
},
|
78 |
+
|
79 |
+
moveimage: function($tracker, $maginner, $cursorshade, e){
|
80 |
+
var specs=$tracker.data('specs'), csw = Math.round(specs.magsize.w/specs.curpower), csh = Math.round(specs.magsize.h/specs.curpower),
|
81 |
+
csb = specs.csborder, fiz = this, imgcoords=specs.coords, pagex=(e.pageX || specs.lastpagex), pagey=(e.pageY || specs.lastpagey),
|
82 |
+
x=pagex-imgcoords.left, y=pagey-imgcoords.top;
|
83 |
+
$cursorshade.css({ // keep shaded area sized and positioned proportionately to area being magnified
|
84 |
+
visibility: '',
|
85 |
+
width: csw,
|
86 |
+
height: csh,
|
87 |
+
top: Math.min(specs.imagesize.h-csh-csb, Math.max(0, y-(csb+csh)/2)) + imgcoords.top,
|
88 |
+
left: Math.min(specs.imagesize.w-csw-csb, Math.max(0, x-(csb+csw)/2)) + imgcoords.left
|
89 |
+
});
|
90 |
+
var newx=-x*specs.curpower+specs.magsize.w/2 //calculate x coord to move enlarged image
|
91 |
+
var newy=-y*specs.curpower+specs.magsize.h/2
|
92 |
+
$maginner.css({left:fiz.getboundary('left', newx, specs), top:fiz.getboundary('top', newy, specs)})
|
93 |
+
specs.$statusdiv.css({left:pagex-10, top:pagey+20})
|
94 |
+
specs.lastpagex=pagex //cache last pagex value (either e.pageX or lastpagex), as FF1.5 returns undefined for e.pageX for "DOMMouseScroll" event
|
95 |
+
specs.lastpagey=pagey
|
96 |
+
},
|
97 |
+
|
98 |
+
magnifyimage: function($tracker, e, zoomrange){
|
99 |
+
if (!e.detail && !e.wheelDelta){e = e.originalEvent;}
|
100 |
+
var delta=e.detail? e.detail*(-120) : e.wheelDelta //delta returns +120 when wheel is scrolled up, -120 when scrolled down
|
101 |
+
var zoomdir=(delta<=-120)? "out" : "in"
|
102 |
+
var specs=$tracker.data('specs')
|
103 |
+
var magnifier=specs.magnifier, od=specs.imagesize, power=specs.curpower
|
104 |
+
var newpower=(zoomdir=="in")? Math.min(power+1, zoomrange[1]) : Math.max(power-1, zoomrange[0]) //get new power
|
105 |
+
var nd=[od.w*newpower, od.h*newpower] //calculate dimensions of new enlarged image within magnifier
|
106 |
+
magnifier.$image.css({width:nd[0], height:nd[1]})
|
107 |
+
specs.curpower=newpower //set current power to new power after magnification
|
108 |
+
specs.$statusdiv.html('Current Zoom: '+specs.curpower)
|
109 |
+
this.showstatusdiv(specs, 0, 500)
|
110 |
+
$tracker.trigger('mousemove')
|
111 |
+
},
|
112 |
+
|
113 |
+
init: function($, $img, options){
|
114 |
+
var setting=$.extend({}, this.dsetting, options), w = $img.width(), h = $img.height(), o = $img.offset(),
|
115 |
+
fiz = this, $tracker, $cursorshade, $statusdiv, $magnifier, lastpage = {pageX: 0, pageY: 0};
|
116 |
+
setting.largeimage = setting.largeimage || $img.get(0).src;
|
117 |
+
$magnifier=$('<div class="magnifyarea" style="position:absolute;width:'+setting.magnifiersize[0]+'px;height:'+setting.magnifiersize[1]+'px;left:-10000px;top:-10000px;visibility:hidden;overflow:hidden;border:1px solid black;" />')
|
118 |
+
.append('<div style="position:relative;left:0;top:0;" />')
|
119 |
+
.appendTo(document.body) //create magnifier container
|
120 |
+
//following lines - create featured image zoomer divs, and absolutely positioned them for placement over the thumbnail and each other:
|
121 |
+
if(setting.cursorshade){
|
122 |
+
$cursorshade = $('<div class="cursorshade" style="visibility:hidden;position:absolute;left:0;top:0;" />')
|
123 |
+
.css({border: setting.cursorshadeborder, opacity: setting.cursorshadeopacity, backgroundColor: setting.cursorshadecolor})
|
124 |
+
.appendTo(document.body);
|
125 |
+
} else {
|
126 |
+
$cursorshade = $('<div />'); //dummy shade div to satisfy $tracker.data('specs')
|
127 |
+
}
|
128 |
+
$statusdiv = $('<div class="zoomstatus preloadevt" style="position:absolute;visibility:hidden;left:0;top:0;" />')
|
129 |
+
.html('<img src="'+this.loadinggif+'" />')
|
130 |
+
.appendTo(document.body); //create DIV to show "loading" gif/ "Current Zoom" info
|
131 |
+
$tracker = $('<div class="zoomtracker" style="cursor:progress;position:absolute;left:'+o.left+'px;top:'+o.top+'px;height:'+h+'px;width:'+w+'px;" />')
|
132 |
+
.css({backgroundImage: (this.isie? 'url(cannotbe)' : 'none')})
|
133 |
+
.appendTo(document.body);
|
134 |
+
$(window).resize(function(){ //in case resizing the window repostions the image
|
135 |
+
var o = $img.offset();
|
136 |
+
$tracker.css({left: o.left, top: o.top});
|
137 |
+
});
|
138 |
+
|
139 |
+
function getspecs($maginner, $bigimage){ //get specs function
|
140 |
+
var magsize={w:$magnifier.width(), h:$magnifier.height()}
|
141 |
+
var imagesize={w:w, h:h}
|
142 |
+
var power=(setting.zoomrange)? setting.zoomrange[0] : ($bigimage.width()/w).toFixed(5)
|
143 |
+
$tracker.data('specs', {
|
144 |
+
$statusdiv: $statusdiv,
|
145 |
+
statustimer: null,
|
146 |
+
magnifier: {$outer:$magnifier, $inner:$maginner, $image:$bigimage},
|
147 |
+
magsize: magsize,
|
148 |
+
magpos: setting.magnifierpos,
|
149 |
+
imagesize: imagesize,
|
150 |
+
curpower: power,
|
151 |
+
coords: getcoords(),
|
152 |
+
csborder: $cursorshade.outerWidth(),
|
153 |
+
lo: setting.leftoffset,
|
154 |
+
ro: setting.rightoffset
|
155 |
+
})
|
156 |
+
}
|
157 |
+
|
158 |
+
function getcoords(){ //get coords of thumb image function
|
159 |
+
var offset=$tracker.offset() //get image's tracker div's offset from document
|
160 |
+
return {left:offset.left, top:offset.top}
|
161 |
+
}
|
162 |
+
|
163 |
+
$tracker.mouseover(function(e){
|
164 |
+
$cursorshade.add($magnifier).add($statusdiv).removeClass('featuredimagezoomerhidden');
|
165 |
+
$tracker.data('premouseout', false);
|
166 |
+
}).mouseout(function(e){
|
167 |
+
$cursorshade.add($magnifier).add($statusdiv.not('.preloadevt')).addClass('featuredimagezoomerhidden');
|
168 |
+
$tracker.data('premouseout', true);
|
169 |
+
}).mousemove(function(e){ //save tracker mouse position for initial magnifier appearance, if needed
|
170 |
+
lastpage.pageX = e.pageX;
|
171 |
+
lastpage.pageY = e.pageY;
|
172 |
+
});
|
173 |
+
|
174 |
+
$tracker.one('mouseover', function(e){
|
175 |
+
var $maginner=$magnifier.find('div:eq(0)')
|
176 |
+
var $bigimage=$('<img src="'+setting.largeimage+'"/>').appendTo($maginner)
|
177 |
+
var showstatus=setting.zoomrange && setting.zoomrange[1]>setting.zoomrange[0]
|
178 |
+
$img.css({opacity:0.1}) //"dim" image while large image is loading
|
179 |
+
var imgcoords=getcoords()
|
180 |
+
$statusdiv.css({left:imgcoords.left+w/2-$statusdiv.width()/2, top:imgcoords.top+h/2-$statusdiv.height()/2, visibility:'visible'})
|
181 |
+
$bigimage.bind('loadevt', function(){ //magnified image ONLOAD event function (to be triggered later)
|
182 |
+
$img.css({opacity:1}) //restore thumb image opacity
|
183 |
+
$statusdiv.empty().css({border:'1px solid black', background:'#C0C0C0', padding:'4px', font:'bold 13px Arial', opacity:0.8}).hide().removeClass('preloadevt');
|
184 |
+
if($tracker.data('premouseout')){
|
185 |
+
$statusdiv.addClass('featuredimagezoomerhidden');
|
186 |
+
}
|
187 |
+
if (setting.zoomrange){ //if set large image to a specific power
|
188 |
+
var nd=[w*setting.zoomrange[0], h*setting.zoomrange[0]] //calculate dimensions of new enlarged image
|
189 |
+
$bigimage.css({width:nd[0], height:nd[1]})
|
190 |
+
}
|
191 |
+
getspecs($maginner, $bigimage) //remember various info about thumbnail and magnifier
|
192 |
+
$magnifier.css({display:'none', visibility:'visible'})
|
193 |
+
$tracker.mouseover(function(e){ //image onmouseover
|
194 |
+
$tracker.data('specs').coords=getcoords() //refresh image coords (from upper left edge of document)
|
195 |
+
fiz.showimage($, $tracker, $magnifier, showstatus)
|
196 |
+
})
|
197 |
+
$tracker.mousemove(function(e){ //image onmousemove
|
198 |
+
fiz.moveimage($tracker, $maginner, $cursorshade, e)
|
199 |
+
})
|
200 |
+
if (!$tracker.data('premouseout')){
|
201 |
+
fiz.showimage($, $tracker, $magnifier, showstatus);
|
202 |
+
fiz.moveimage($tracker, $maginner, $cursorshade, lastpage);
|
203 |
+
}
|
204 |
+
$tracker.mouseout(function(e){ //image onmouseout
|
205 |
+
fiz.hideimage($tracker, $magnifier, showstatus)
|
206 |
+
}).css({cursor: fiz.magnifycursor});
|
207 |
+
if (setting.zoomrange && setting.zoomrange[1]>setting.zoomrange[0]){ //if zoom range enabled
|
208 |
+
$tracker.bind('DOMMouseScroll mousewheel', function(e){
|
209 |
+
fiz.magnifyimage($tracker, e, setting.zoomrange);
|
210 |
+
e.preventDefault();
|
211 |
+
});
|
212 |
+
}
|
213 |
+
}) //end $bigimage onload
|
214 |
+
if ($bigimage.get(0).complete){ //if image has already loaded (account for IE, Opera not firing onload event if so)
|
215 |
+
$bigimage.trigger('loadevt')
|
216 |
+
}
|
217 |
+
else{
|
218 |
+
$bigimage.bind('load', function(){$bigimage.trigger('loadevt')})
|
219 |
+
}
|
220 |
+
})
|
221 |
+
},
|
222 |
+
|
223 |
+
iname: (function(){var itag = jQuery('<img />'), iname = itag.get(0).tagName; itag.remove(); return iname;})()
|
224 |
+
};
|
225 |
+
|
226 |
+
jQuery.fn.addimagezoom=function(options){
|
227 |
+
var $=jQuery;
|
228 |
+
return this.each(function(){ //return jQuery obj
|
229 |
+
if (this.tagName !== featuredimagezoomer.iname)
|
230 |
+
return true; //skip to next matched element
|
231 |
+
featuredimagezoomer.init($, $(this), options);
|
232 |
+
});
|
233 |
+
}
|