straker-translations-easy-translation-platform - Version 0.3.0

Version Notes

Initial development version

Download this release

Release Info

Developer Chris
Extension straker-translations-easy-translation-platform
Version 0.3.0
Comparing to
See all releases


Code changes from version 0.2.0 to 0.3.0

Files changed (28) hide show
  1. app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Job/Category.php +1 -1
  2. app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Job/Grid.php +10 -0
  3. app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Job/Product.php +1 -1
  4. app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Job/Product/Grid.php +7 -7
  5. app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/New/Category/Confirm/Grid.php +41 -0
  6. app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/New/Products/Grid.php +29 -0
  7. app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/System/Config/Form/Store.php +48 -0
  8. app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Template/Grid/Renderer/Action.php +2 -2
  9. app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Template/Grid/Renderer/Backend.php +4 -1
  10. app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Template/Grid/Renderer/Frontend.php +4 -1
  11. app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Template/Grid/Renderer/Status.php +4 -0
  12. app/code/community/StrakerTranslations/EasyTranslationPlatform/Model/Job.php +26 -0
  13. app/code/community/StrakerTranslations/EasyTranslationPlatform/Model/Resource/Job/Category/Collection.php +11 -0
  14. app/code/community/StrakerTranslations/EasyTranslationPlatform/Model/Resource/Job/Product/Collection.php +11 -0
  15. app/code/community/StrakerTranslations/EasyTranslationPlatform/controllers/Adminhtml/JobController.php +0 -123
  16. app/code/community/StrakerTranslations/EasyTranslationPlatform/controllers/Adminhtml/NewController.php +0 -196
  17. app/code/community/StrakerTranslations/EasyTranslationPlatform/controllers/Adminhtml/ProductController.php +0 -63
  18. app/code/community/StrakerTranslations/EasyTranslationPlatform/controllers/Adminhtml/Straker/NewController.php +20 -0
  19. app/code/community/StrakerTranslations/EasyTranslationPlatform/etc/adminhtml.xml +7 -2
  20. app/code/community/StrakerTranslations/EasyTranslationPlatform/etc/config.xml +10 -10
  21. app/code/community/StrakerTranslations/EasyTranslationPlatform/etc/system.xml +96 -87
  22. app/code/community/StrakerTranslations/EasyTranslationPlatform/sql/strakertranslations_easytranslationplatform_setup/mysql4-upgrade-0.2.0-0.3.0.php +26 -0
  23. app/design/adminhtml/default/straker/template/straker/system/config/store.phtml +13 -0
  24. js/straker/livepipe/livepipe.js +0 -181
  25. js/straker/livepipe/window.js +0 -947
  26. package.xml +4 -4
  27. skin/adminhtml/default/straker/css/straker.css +124 -104
  28. skin/adminhtml/default/straker/css/straker.less +126 -0
app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Job/Category.php CHANGED
@@ -12,7 +12,7 @@ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Job_Category e
12
$jobStatus = Mage::getModel('strakertranslations_easytranslationplatform/job')->load($jobId)->getStatusId();
13
if ( $jobStatus == '4'){
14
$this->_addButton('publish', array(
15
- 'label' => Mage::helper('catalog')->__('Publish Translation'),
16
'onclick' => "setLocation('{$this->getUrl('*/*/copyAll',array('job_id'=>$jobId))}');",
17
'class' => 'task'
18
));
12
$jobStatus = Mage::getModel('strakertranslations_easytranslationplatform/job')->load($jobId)->getStatusId();
13
if ( $jobStatus == '4'){
14
$this->_addButton('publish', array(
15
+ 'label' => Mage::helper('catalog')->__('Publish All Translations'),
16
'onclick' => "setLocation('{$this->getUrl('*/*/copyAll',array('job_id'=>$jobId))}');",
17
'class' => 'task'
18
));
app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Job/Grid.php CHANGED
@@ -12,6 +12,16 @@ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Job_Grid exten
12
13
protected function _prepareCollection() {
14
$collection = Mage::getModel('strakertranslations_easytranslationplatform/job')->getCollection();
15
$collection->getSelect()->joinLeft(
16
'straker_job_type',
17
'straker_job_type.type_id = main_table.type_id',
12
13
protected function _prepareCollection() {
14
$collection = Mage::getModel('strakertranslations_easytranslationplatform/job')->getCollection();
15
+
16
+ foreach($collection as $jobModel){
17
+ if($jobModel->getStatusId() == 4){
18
+ $jobModel->load($jobModel->getId())->isPublished();
19
+ }
20
+ }
21
+
22
+
23
+ $collection = Mage::getModel('strakertranslations_easytranslationplatform/job')->getCollection();
24
+
25
$collection->getSelect()->joinLeft(
26
'straker_job_type',
27
'straker_job_type.type_id = main_table.type_id',
app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Job/Product.php CHANGED
@@ -12,7 +12,7 @@ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Job_Product ex
12
$jobStatus = Mage::getModel('strakertranslations_easytranslationplatform/job')->load($jobId)->getStatusId();
13
if ( $jobStatus == '4'){
14
$this->_addButton('publish', array(
15
- 'label' => Mage::helper('catalog')->__('Publish Translation'),
16
'onclick' => "setLocation('{$this->getUrl('*/*/copyAll',array('job_id'=>$jobId))}');",
17
'class' => 'task'
18
));
12
$jobStatus = Mage::getModel('strakertranslations_easytranslationplatform/job')->load($jobId)->getStatusId();
13
if ( $jobStatus == '4'){
14
$this->_addButton('publish', array(
15
+ 'label' => Mage::helper('catalog')->__('Publish All Translations'),
16
'onclick' => "setLocation('{$this->getUrl('*/*/copyAll',array('job_id'=>$jobId))}');",
17
'class' => 'task'
18
));
app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Job/Product/Grid.php CHANGED
@@ -46,12 +46,12 @@ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Job_Product_Gr
46
}
47
48
protected function _prepareColumns() {
49
- // $this->addColumn('id', array(
50
- // 'header' => Mage::helper('strakertranslations_easytranslationplatform')->__('ID'),
51
- // 'align' => 'right',
52
- // 'width' => '50px',
53
- // 'index' => 'id',
54
- // ));
55
56
$this->addColumn('product_id', array(
57
'header' => Mage::helper('strakertranslations_easytranslationplatform')->__('Product ID'),
@@ -137,7 +137,7 @@ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Job_Product_Gr
137
$this->getMassactionBlock()->setHiddenParams($hiddenParams);
138
139
140
- Mage::dispatchEvent('adminhtml_strakertranslation_job_product_grid_prepare_massaction', array('block' => $this));
141
return $this;
142
}
143
}
46
}
47
48
protected function _prepareColumns() {
49
+ $this->addColumn('id', array(
50
+ 'header' => Mage::helper('strakertranslations_easytranslationplatform')->__('ID'),
51
+ 'align' => 'right',
52
+ 'width' => '50px',
53
+ 'index' => 'id',
54
+ ));
55
56
$this->addColumn('product_id', array(
57
'header' => Mage::helper('strakertranslations_easytranslationplatform')->__('Product ID'),
137
$this->getMassactionBlock()->setHiddenParams($hiddenParams);
138
139
140
+ // Mage::dispatchEvent('adminhtml_strakertranslation_job_product_grid_prepare_massaction', array('block' => $this));
141
return $this;
142
}
143
}
app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/New/Category/Confirm/Grid.php CHANGED
@@ -33,6 +33,13 @@ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_New_Category_C
33
$collection->addAttributeToSelect($attr);
34
}
35
36
$this->setCollection($collection);
37
38
parent::_prepareCollection();
@@ -40,6 +47,20 @@ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_New_Category_C
40
return $this;
41
}
42
43
protected function _prepareColumns()
44
{
45
@@ -50,6 +71,7 @@ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_New_Category_C
50
'type' => 'number',
51
'index' => 'entity_id',
52
'filter' => false,
53
));
54
55
if (in_array('name',$this->getAttrArray())) {
@@ -58,6 +80,7 @@ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_New_Category_C
58
'header' => Mage::helper('catalog')->__('Name to translate'),
59
'index' => 'name',
60
'filter' => false,
61
));
62
}
63
else{
@@ -66,6 +89,7 @@ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_New_Category_C
66
'header' => Mage::helper('catalog')->__('Name'),
67
'index' => 'name',
68
'filter' => false,
69
));
70
}
71
@@ -75,6 +99,7 @@ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_New_Category_C
75
'renderer' => 'StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Template_Grid_Renderer_Path',
76
'index' => 'path',
77
'filter' => false,
78
));
79
80
foreach ($this->getAttrArray() as $attr){
@@ -85,10 +110,26 @@ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_New_Category_C
85
'header' => Mage::helper('catalog')->__($attrModel->getFrontendLabel()) .' to Translate',
86
'index' => $attr,
87
'filter' => false,
88
));
89
}
90
}
91
92
return parent::_prepareColumns();
93
}
94
33
$collection->addAttributeToSelect($attr);
34
}
35
36
+ //join straker job product table to get version for each product
37
+ $collection->getSelect()->joinLeft(
38
+ 'straker_job_category',
39
+ 'straker_job_category.category_id = e.entity_id',
40
+ 'version'
41
+ );
42
+
43
$this->setCollection($collection);
44
45
parent::_prepareCollection();
47
return $this;
48
}
49
50
+ // protected function _addColumnFilterToCollection($column)
51
+ // {
52
+ //
53
+ // if ($column->getId() == 'version') {
54
+ // $this->getCollection()->joinField('version',
55
+ // 'straker_job_category',
56
+ // 'version',
57
+ // 'category_id=entity_id',
58
+ // null,
59
+ // 'left');
60
+ // }
61
+ //
62
+ // }
63
+
64
protected function _prepareColumns()
65
{
66
71
'type' => 'number',
72
'index' => 'entity_id',
73
'filter' => false,
74
+ 'sortable' => false
75
));
76
77
if (in_array('name',$this->getAttrArray())) {
80
'header' => Mage::helper('catalog')->__('Name to translate'),
81
'index' => 'name',
82
'filter' => false,
83
+ 'sortable' => false
84
));
85
}
86
else{
89
'header' => Mage::helper('catalog')->__('Name'),
90
'index' => 'name',
91
'filter' => false,
92
+ 'sortable' => false
93
));
94
}
95
99
'renderer' => 'StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Template_Grid_Renderer_Path',
100
'index' => 'path',
101
'filter' => false,
102
+ 'sortable' => false
103
));
104
105
foreach ($this->getAttrArray() as $attr){
110
'header' => Mage::helper('catalog')->__($attrModel->getFrontendLabel()) .' to Translate',
111
'index' => $attr,
112
'filter' => false,
113
+ 'sortable' => false
114
));
115
}
116
}
117
118
+ $this->addColumn('version',
119
+ array(
120
+ 'header'=> Mage::helper('catalog')->__('Translated'),
121
+ 'width' => '70px',
122
+ 'index' => 'version',
123
+ 'type' => 'options',
124
+ 'filter' => false,
125
+ 'sortable' => false,
126
+ 'options' => array(
127
+ 1 => Mage::helper('catalog')->__('Translated'),
128
+ '' => Mage::helper('catalog')->__('Not Translated')
129
+ )
130
+ ));
131
+
132
+
133
return parent::_prepareColumns();
134
}
135
app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/New/Products/Grid.php CHANGED
@@ -64,6 +64,13 @@ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_New_Products_G
64
$collection->joinAttribute('visibility', 'catalog_product/visibility', 'entity_id', null, 'inner');
65
}
66
67
$this->setCollection($collection);
68
69
parent::_prepareCollection();
@@ -82,6 +89,16 @@ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_New_Products_G
82
null,
83
'left');
84
}
85
}
86
return parent::_addColumnFilterToCollection($column);
87
}
@@ -146,6 +163,18 @@ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_New_Products_G
146
'options' => Mage::getSingleton('catalog/product_status')->getOptionArray(),
147
));
148
149
if (!Mage::app()->isSingleStoreMode()) {
150
$this->addColumn('websites',
151
array(
64
$collection->joinAttribute('visibility', 'catalog_product/visibility', 'entity_id', null, 'inner');
65
}
66
67
+ //join straker job product table to get version for each product
68
+ $collection->getSelect()->joinLeft(
69
+ 'straker_job_product',
70
+ 'straker_job_product.product_id = e.entity_id',
71
+ 'version'
72
+ );
73
+
74
$this->setCollection($collection);
75
76
parent::_prepareCollection();
89
null,
90
'left');
91
}
92
+
93
+ if ($column->getId() == 'version') {
94
+ $this->getCollection()->joinField('version',
95
+ 'straker_job_product',
96
+ 'version',
97
+ 'product_id=entity_id',
98
+ null,
99
+ 'left');
100
+ }
101
+
102
}
103
return parent::_addColumnFilterToCollection($column);
104
}
163
'options' => Mage::getSingleton('catalog/product_status')->getOptionArray(),
164
));
165
166
+ $this->addColumn('version',
167
+ array(
168
+ 'header'=> Mage::helper('catalog')->__('Translated'),
169
+ 'width' => '70px',
170
+ 'index' => 'version',
171
+ 'type' => 'options',
172
+ 'options' => array(
173
+ 1 => Mage::helper('catalog')->__('Translated'),
174
+ '' => Mage::helper('catalog')->__('Not Translated')
175
+ )
176
+ ));
177
+
178
if (!Mage::app()->isSingleStoreMode()) {
179
$this->addColumn('websites',
180
array(
app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/System/Config/Form/Store.php ADDED
@@ -0,0 +1,48 @@
1
+ <?php
2
+ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_System_Config_Form_Store extends Mage_Adminhtml_Block_System_Config_Form_Field
3
+ {
4
+ /*
5
+ * Set template
6
+ */
7
+ protected function _construct()
8
+ {
9
+ parent::_construct();
10
+ $this->setTemplate('straker/system/config/store.phtml');
11
+ }
12
+
13
+ /**
14
+ * Return element html
15
+ *
16
+ * @param Varien_Data_Form_Element_Abstract $element
17
+ * @return string
18
+ */
19
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
20
+ {
21
+ return $this->_toHtml();
22
+ }
23
+
24
+ /**
25
+ * Generate button html
26
+ *
27
+ * @return string
28
+ */
29
+ public function getClearStoreButtonHtml($store)
30
+ {
31
+ if ($store->getId() && Mage::helper('strakertranslations_easytranslationplatform')->getStoreSetup($store->getId())) {
32
+ $button = $this->getLayout()->createBlock('adminhtml/widget_button')
33
+ ->setData(array(
34
+ 'id' => 'straker_clear_store_button_' . $store->getCode(),
35
+ 'label' => $this->helper('adminhtml')->__('Clear'),
36
+ 'onclick' => 'setLocation(\'' . Mage::helper('adminhtml')->getUrl(
37
+ 'adminhtml/straker_new/resetStoreSettings',
38
+ array('store' => $store->getId())
39
+ ) . '\');'
40
+ ));
41
+ return $button->toHtml();
42
+ }
43
+ else{
44
+
45
+ return '<div class="empty-button">'.$this->__('No settings found.').'</div>';
46
+ }
47
+ }
48
+ }
app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Template/Grid/Renderer/Action.php CHANGED
@@ -6,9 +6,9 @@ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Template_Grid_
6
{
7
if (get_class($row) == get_class(Mage::getModel('strakertranslations_easytranslationplatform/job'))) {
8
9
- $buttonText = $row->getStatusId() == 4 ? $this->__('Publish') : $this->__('View Order');
10
11
- $out = '<button id="button-update-'.$row->getId().'" style="margin: 5px; display: block;" onclick="event.stopPropagation(); setLocation(\'' . Mage::helper("adminhtml")->getUrl("adminhtml/straker_".strtolower($row->getTypeName()).'/', array('job_id' => $row->getId())) . '\')" title="View Order" type="button" style="">'.$buttonText.'</button>';
12
return $out;
13
}
14
}
6
{
7
if (get_class($row) == get_class(Mage::getModel('strakertranslations_easytranslationplatform/job'))) {
8
9
+ $buttonText = $row->getStatusId() == 4 ? $this->__('Publish') : $this->__('View');
10
11
+ $out = '<button id="button-update-'.$row->getId().'" style="margin: 5px; display: block;" onclick="event.stopPropagation(); setLocation(\'' . Mage::helper("adminhtml")->getUrl("adminhtml/straker_".strtolower($row->getTypeName()).'/', array('job_id' => $row->getId())) . '\')" title="View" type="button" style="">'.$buttonText.'</button>';
12
return $out;
13
}
14
}
app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Template/Grid/Renderer/Backend.php CHANGED
@@ -6,7 +6,10 @@ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Template_Grid_
6
7
public function render(Varien_Object $row){
8
$html = '';
9
- if ($row->getProductId()) {
10
$product = Mage::getModel('catalog/product')->load($row->getProductId());
11
$url = $this->getUrl('adminhtml/catalog_product/edit', array(
12
'store' => $this->getStoreId($row),
6
7
public function render(Varien_Object $row){
8
$html = '';
9
+ if(!$row->getVersion()){
10
+ $html .= '<p class="inactive">' . $this->__('View Product in Backend') . '</p>';
11
+ }
12
+ elseif ($row->getProductId()) {
13
$product = Mage::getModel('catalog/product')->load($row->getProductId());
14
$url = $this->getUrl('adminhtml/catalog_product/edit', array(
15
'store' => $this->getStoreId($row),
app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Template/Grid/Renderer/Frontend.php CHANGED
@@ -6,7 +6,10 @@ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Template_Grid_
6
7
public function render(Varien_Object $row){
8
$html = '';
9
- if ($row->getProductId()) {
10
$product = Mage::getModel('catalog/product')->setStoreId($this->getStoreId($row))->load($row->getProductId());
11
if (!$product->isDisabled() && $product->isVisibleInSiteVisibility()) {
12
$html .= '<a target="_blank" href="' . $product->getProductUrl() . '">' . $this->__('View Product in Frontend') . '</a>';
6
7
public function render(Varien_Object $row){
8
$html = '';
9
+ if(!$row->getVersion()){
10
+ $html .= '<p class="inactive">' . $this->__('View Product in Frontend') . '</p>';
11
+ }
12
+ elseif ($row->getProductId()) {
13
$product = Mage::getModel('catalog/product')->setStoreId($this->getStoreId($row))->load($row->getProductId());
14
if (!$product->isDisabled() && $product->isVisibleInSiteVisibility()) {
15
$html .= '<a target="_blank" href="' . $product->getProductUrl() . '">' . $this->__('View Product in Frontend') . '</a>';
app/code/community/StrakerTranslations/EasyTranslationPlatform/Block/Adminhtml/Template/Grid/Renderer/Status.php CHANGED
@@ -25,6 +25,10 @@ class StrakerTranslations_EasyTranslationPlatform_Block_Adminhtml_Template_Grid_
25
elseif ($row->getStatusName() == 'COMPLETED') {
26
$html = $this->__('Ready to Publish');
27
}
28
return $html;
29
}
30
25
elseif ($row->getStatusName() == 'COMPLETED') {
26
$html = $this->__('Ready to Publish');
27
}
28
+ //else if status is PUBLISHED
29
+ elseif ($row->getStatusName() == 'PUBLISHED') {
30
+ $html = $this->__('Published');
31
+ }
32
return $html;
33
}
34
app/code/community/StrakerTranslations/EasyTranslationPlatform/Model/Job.php CHANGED
@@ -444,6 +444,32 @@ class StrakerTranslations_EasyTranslationPlatform_Model_Job extends Mage_Core_Mo
444
return true;
445
}
446
447
public function submitSupport(array $data){
448
449
$res = $this->_getApi()->callSupport($data);
444
return true;
445
}
446
447
+ public function isPublished()
448
+ {
449
+ if ($this->getStatusId() == 5) {
450
+ return true;
451
+ } elseif($this->getStatusId() == 4) {
452
+ return $this->updatePublishedStatus()->getStatus() == 5;
453
+ }
454
+ else{
455
+ return false;
456
+ }
457
+ }
458
+
459
+ protected function updatePublishedStatus(){
460
+ $collection = Mage::getModel('strakertranslations_easytranslationplatform/job_'.$this->_getType())->getCollection()->addFieldToFilter('job_id',$this->getId());
461
+ $collection->addFieldToFilter('version',
462
+ array(
463
+ array('neq' => '1'),
464
+ array('null' => true)
465
+ )
466
+ );
467
+ if(!$collection->getFirstItem()->getId()){
468
+ $this->setStatusId(5)->save();
469
+ }
470
+ return $this;
471
+ }
472
+
473
public function submitSupport(array $data){
474
475
$res = $this->_getApi()->callSupport($data);
app/code/community/StrakerTranslations/EasyTranslationPlatform/Model/Resource/Job/Category/Collection.php CHANGED
@@ -13,4 +13,15 @@ class StrakerTranslations_EasyTranslationPlatform_Model_Resource_Job_Category_Co
13
$this->_init('strakertranslations_easytranslationplatform/job_category');
14
}
15
16
}
13
$this->_init('strakertranslations_easytranslationplatform/job_category');
14
}
15
16
+ public function getAllIds()
17
+ {
18
+ $idsSelect = clone $this->getSelect();
19
+ $idsSelect->reset(Zend_Db_Select::ORDER);
20
+ $idsSelect->reset(Zend_Db_Select::LIMIT_COUNT);
21
+ $idsSelect->reset(Zend_Db_Select::LIMIT_OFFSET);
22
+ $idsSelect->reset(Zend_Db_Select::COLUMNS);
23
+
24
+ $idsSelect->columns('category_id', 'main_table');
25
+ return $this->getConnection()->fetchCol($idsSelect);
26
+ }
27
}
app/code/community/StrakerTranslations/EasyTranslationPlatform/Model/Resource/Job/Product/Collection.php CHANGED
@@ -13,4 +13,15 @@ class StrakerTranslations_EasyTranslationPlatform_Model_Resource_Job_Product_Col
13
$this->_init('strakertranslations_easytranslationplatform/job_product');
14
}
15
16
}
13
$this->_init('strakertranslations_easytranslationplatform/job_product');
14
}
15
16
+ public function getAllIds()
17
+ {
18
+ $idsSelect = clone $this->getSelect();
19
+ $idsSelect->reset(Zend_Db_Select::ORDER);
20
+ $idsSelect->reset(Zend_Db_Select::LIMIT_COUNT);
21
+ $idsSelect->reset(Zend_Db_Select::LIMIT_OFFSET);
22
+ $idsSelect->reset(Zend_Db_Select::COLUMNS);
23
+
24
+ $idsSelect->columns('product_id', 'main_table');
25
+ return $this->getConnection()->fetchCol($idsSelect);
26
+ }
27
}
app/code/community/StrakerTranslations/EasyTranslationPlatform/controllers/Adminhtml/JobController.php DELETED
@@ -1,123 +0,0 @@
1
- <?php
2
- Class StrakerTranslations_EasyTranslationPlatform_Adminhtml_JobController extends Mage_Adminhtml_Controller_Action{
3
- protected function _isAllowed()
4
- {
5
- return Mage::getSingleton('admin/session')->isAllowed('admin/straker/job');
6
- }
7
-
8
- protected function _initAction()
9
- {
10
- $this
11
- ->loadLayout()
12
- ->_setActiveMenu('straker/job')
13
- ;
14
-
15
- return $this;
16
- }
17
-
18
- public function indexAction(){
19
- $this->_title($this->__('Straker Translations'))
20
- ->_title($this->__('Manage Jobs'));
21
-
22
- $this->loadLayout();
23
- $this->renderLayout();
24
- }
25
-
26
- public function updateJobAction() {
27
-
28
- $data = $this->getRequest()->getParams();
29
- if($data['job_id']){
30
- $job = Mage::getModel('strakertranslations_easytranslationplatform/job')->load((int) $data['job_id']);
31
-
32
- if(!$job->getJobKey()){
33
- return false;
34
- }
35
-
36
-
37
- switch ($job->getStatusName()){
38
-
39
- Case 'QUEUED' :
40
-
41
- if ($job->getPaymentStatus()){
42
- if( $job->updateTranslation() ){
43
- Mage::getSingleton('core/session')->addSuccess($this->__('Job %s has been updated.', $job->getId()));
44
- }
45
- } else {
46
-
47
- if($job->updatePayment()){
48
- if( $job->updateTranslation() ){
49
- Mage::getSingleton('core/session')->addSuccess($this->__('Job %s has been updated.', $job->getId()));
50
- }
51
-
52
- }elseif($job->updateQuote()){
53
- Mage::getSingleton('core/session')->addSuccess($this->__('Job %s has been updated.', $job->getId()));
54
- }
55
-
56
- }
57
-
58
- $this->_redirect('*/*/');
59
- return;
60
- break;
61
-
62
- default:
63
- if( $job->updateTranslation() ){
64
- Mage::getSingleton('core/session')->addSuccess($this->__('Job %s has been updated.', $job->getId()));
65
- }
66
- $this->_redirect('*/*/');
67
- return;
68
-
69
- }
70
-
71
- }
72
-
73
- return false;
74
-
75
- }
76
-
77
-
78
- public function disputeAction() {
79
- $data = $this->getRequest()->getParams();
80
- if($data['job_id'] && $data['message']){
81
- $job = Mage::getModel('strakertranslations_easytranslationplatform/job')->load((int) $data['job_id']);
82
-
83
-
84
- $response = $job->submitSupport(array(
85
- 'title' => 'Dispute for '.$job->getTjNumber(),
86
- 'message' => $data['message']
87
- ));
88
-
89
- //Send out email
90
-
91
- $mail = new Zend_Mail(); //class for mail
92
- $mail->setBodyHtml($data['message']); //for sending message containing html code
93
- $mail->setFrom(Mage::getStoreConfig('trans_email/ident_general/email'), Mage::getStoreConfig('trans_email/ident_general/name'));
94
- $mail->addTo('processing@strakertranslations.com', 'Straker Support');
95
- $mail->setSubject('Dispute for '.$job->getTjNumber());
96
- $msg ='';
97
- Mage::log(print_r($mail,true), null , 'debugging.log' , true);
98
- try {
99
- if($mail->send())
100
- {
101
- $msg = true;
102
- }
103
- }
104
- catch(Exception $ex) {
105
- $msg = false;
106
- }
107
- if($msg){
108
- Mage::getSingleton('adminhtml/session')->addSuccess('Dispute has been submitted.');
109
- }
110
- else{
111
- Mage::getSingleton('adminhtml/session')->addError('Unkown error when sending email to processing@strakertranslations.com.');
112
- }
113
- }
114
- else{
115
- Mage::getSingleton('adminhtml/session')->addError('Required parameters missing when submitting a dispute.');
116
- }
117
- $this->_redirect('straker/adminhtml_product/index', array(
118
- 'job_id' => $data['job_id']
119
- ));
120
- return;
121
- }
122
-
123
- }
app/code/community/StrakerTranslations/EasyTranslationPlatform/controllers/Adminhtml/NewController.php DELETED
@@ -1,196 +0,0 @@
1
- <?php
2
- Class StrakerTranslations_EasyTranslationPlatform_Adminhtml_NewController extends Mage_Adminhtml_Controller_Action{
3
- protected function _isAllowed()
4
- {
5
- return Mage::getSingleton('admin/session')->isAllowed('admin/straker/new');
6
- }
7
-
8
- protected function _initAction()
9
- {
10
- $this
11
- ->loadLayout()
12
- ->_setActiveMenu('straker/new')
13
- ;
14
- $this->_title($this->__('Create New Job'));
15
- return $this;
16
- }
17
-
18
- public function indexAction(){
19
- $params = $this->getRequest()->getParams();
20
- if (Mage::helper('strakertranslations_easytranslationplatform')->getAppKey() === false || Mage::helper('strakertranslations_easytranslationplatform')->getAccessToken() === false){
21
- return $this->_initAction()
22
- ->_addContent(Mage::getSingleton('core/layout')->createBlock('strakertranslations_easytranslationplatform/adminhtml_new_register'))
23
- ->renderLayout();
24
- }
25
- elseif (empty($params['store'])){
26
- return $this->_initAction()
27
- ->_addContent(Mage::getSingleton('core/layout')->createBlock('strakertranslations_easytranslationplatform/adminhtml_new_selectstore'))
28
- ->renderLayout();
29
- }
30
- elseif ( Mage::helper('strakertranslations_easytranslationplatform')->getStoreSetup($params['store']) === false
31
- ){
32
- return $this->_initAction()
33
- ->_addContent(Mage::getSingleton('core/layout')->createBlock('strakertranslations_easytranslationplatform/adminhtml_new_setupstore', 'strakertranslations_easytranslationplatform_new_setupstore', array('setup_store_id' => $params['store'])))
34
- ->renderLayout();
35
- }
36
- elseif (empty($params['attr'])) {
37
- return $this->_initAction()
38
- ->_addContent(Mage::getSingleton('core/layout')->createBlock('strakertranslations_easytranslationplatform/adminhtml_new_attribute','strakertranslations_easytranslationplatform_new_attribute',array('setup_store_id' => $params['store'])))
39
- ->renderLayout();
40
- }
41
- else{
42
- return $this->_initAction()
43
- ->_addContent(Mage::getSingleton('core/layout')->createBlock('strakertranslations_easytranslationplatform/adminhtml_new_products','strakertranslations_easytranslationplatform_new_products',array('setup_store_id' => $params['store'], 'attr' => $params['attr'])))
44
- ->renderLayout();
45
- }
46
- }
47
-
48
- public function registerAction(){
49
-
50
- $data = $this->getRequest()->getPost();
51
- if (array_key_exists('form_key', $data)){
52
- unset($data['form_key']);
53
- }
54
- if ($data['first_name'] && $data['last_name'] && $data['email'] && $data['terms']) {
55
- if ($data['company'] == ''){
56
- $data['company'] = $data['first_name'] .' '. $data['last_name'];
57
- }
58
- $apiModel = Mage::getModel('strakertranslations_easytranslationplatform/api');
59
- $response = $apiModel->callRegister($data);
60
- if($response->access_token && $response->application_key) {
61
- $apiModel->saveAccessToken($response->access_token);
62
- $apiModel->saveAppKey($response->application_key);
63
- Mage::getSingleton('adminhtml/session')->addSuccess('Registration success.');
64
- }
65
- elseif($response->magentoMessage){
66
- Mage::getSingleton('adminhtml/session')->addError($response->magentoMessage);
67
- }
68
- else{
69
- Mage::getSingleton('adminhtml/session')->addError('Registration unsuccessful.');
70
- }
71
- }
72
- $this->_redirect('*/*/');
73
- }
74
-
75
- public function selectstoreAction(){
76
- $store = $this->getRequest()->getParam('store');
77
- if($store){
78
- $this->_redirect('*/*/', array('store' => $store));
79
- }
80
- else {
81
- $this->_redirect('*/*/');
82
- }
83
- }
84
-
85
- public function setupstoreAction(){
86
- $data = $this->getRequest()->getParams();
87
- if ($data['store'] && $data['source'] && $data['from'] && $data['to']) {
88
- /** @var $session Mage_Admin_Model_Session */
89
- $session = Mage::getSingleton('adminhtml/session');
90
- try {
91
- //save the source, language from and to in stystem config
92
- $helper = Mage::helper('strakertranslations_easytranslationplatform');
93
-
94
- if ($helper->saveStoreSetup($data['store'], $data['source'], $data['from'], $data['to']) !== false ){
95
- $this->_redirect('*/*/', array('store' => $data['store']));
96
- return;
97
- }
98
- else {
99
- Mage::throwException(Mage::helper('strakertranslations_easytranslationplatform')->__('Unable to save store configurations.'));
100
- }
101
- } catch (Exception $e) {
102
- $session->addError($e->getMessage());
103
- $this->_redirect('*/*/');
104
- return;
105
- }
106
- }
107
- $this->_redirect('*/*/');
108
- }
109
-
110
- public function attributeAction(){
111
- $data = $this->getRequest()->getParams();
112
- if($data['attr'] && $data['store']){
113
- $this->_redirect('*/*/', array('store' => $data['store'], 'attr' => implode(",",array_keys($data['attr']))));
114
- }
115
- else {
116
- $this->_redirect('*/*/');
117
- }
118
- }
119
-
120
- public function addtoconfirmAction(){
121
- $data = $this->getRequest()->getParams();
122
- if($data['attr'] && $data['store'] && $data['product']){
123
- return $this->_initAction()
124
- ->_addContent(Mage::getSingleton('core/layout')->createBlock('strakertranslations_easytranslationplatform/adminhtml_new_confirm', 'strakertranslations_easytranslationplatform_new_confirm', array('store' => $data['store'], 'attr' => $data['attr'], 'product' => $data['product'])))
125
- ->renderLayout();
126
- }
127
- else {
128
- $this->_redirect('*/*/', $data);
129
- }
130
- }
131
-
132
- public function submitjobAction(){
133
- $data = $this->getRequest()->getParams();
134
- if($data['attr'] && $data['store'] && $data['product']){
135
- //todo: refine attribute code and id procedure
136
- $jobModel = Mage::getModel('strakertranslations_easytranslationplatform/job');
137
- try {
138
- $jobModel->checkAndCreateFolder();
139
- }
140
- catch (Mage_Core_Exception $e){
141
- Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
142
- $this->_redirect('*/*/', array(
143
- 'store' => $data['store'],
144
- 'attr' => $data['attr']
145
- ));
146
- return;
147
- }
148
- foreach(explode(',', $data['attr']) as $attributeCode){
149
- $attr_ids[] = $attribute = Mage::getSingleton('eav/config')
150
- ->getAttribute(Mage_Catalog_Model_Product::ENTITY, $attributeCode)->getAttributeId();
151
- }
152
- $helper = Mage::helper('strakertranslations_easytranslationplatform');
153
- $storeSetup = $helper->getStoreSetup($data['store']);
154
- $jobModel->setStoreId($data['store']);
155
- $jobModel->setSl($storeSetup['from']);
156
- $jobModel->setTl($storeSetup['to']);
157
- $jobModel->setTitle('Title');
158
- $jobModel->setToken('Token');
159
- $jobModel->submitProducts($attr_ids, explode(',',$data['product']));
160
- if ($jobModel->getLastStatus()) {
161
- Mage::getSingleton('adminhtml/session')->addSuccess('New job created');
162
- $this->_redirect('*/adminhtml_job/');
163
- }
164
- else{
165
- Mage::getSingleton('adminhtml/session')->addError($jobModel->getLastMessage());
166
- $this->_redirect('*/*/');
167
- }
168
- }
169
- else {
170
- $this->_redirect('*/*/', $data);
171
- }
172
- }
173
-
174
- public function clearSettingsAction()
175
- {
176
- $session = Mage::getSingleton('adminhtml/session');
177
-
178
- try {
179
- $apiModel = Mage::getModel('strakertranslations_easytranslationplatform/api');
180
-
181
- $apiModel->saveAccessToken('');
182
- $apiModel->saveAppKey('');
183
-
184
- $helper = Mage::helper('strakertranslations_easytranslationplatform');
185
- foreach (Mage::app()->getStores() as $store) {
186
- $helper->saveStoreSetup($store->getId(), '', '', '');
187
- }
188
- $session->addSuccess('Straker Settings has been cleared.');
189
-
190
- } catch (Exception $e) {
191
- $session->addError($e->getMessage());
192
- }
193
- $this->_redirect('adminhtml/system_config/edit/section/straker');
194
- return;
195
- }
196
- }
app/code/community/StrakerTranslations/EasyTranslationPlatform/controllers/Adminhtml/ProductController.php DELETED
@@ -1,63 +0,0 @@
1
- <?php
2
- Class StrakerTranslations_EasyTranslationPlatform_Adminhtml_ProductController extends Mage_Adminhtml_Controller_Action{
3
- protected function _isAllowed()
4
- {
5
- return Mage::getSingleton('admin/session')->isAllowed('admin/straker/job');
6
- }
7
-
8
- protected function _initAction()
9
- {
10
- $this
11
- ->loadLayout()
12
- ->_setActiveMenu('straker/job')
13
- ;
14
-
15
- return $this;
16
- }
17
-
18
- public function indexAction(){
19
-
20
- if (!$this->getRequest()->getParam('job_id')){
21
- Mage::getSingleton('adminhtml/session')->addError('Job ID missing');
22
- $this->_redirect('*/adminhtml_job/');
23
- return;
24
- }
25
-
26
- $this->_title($this->__('Straker Translations'))
27
- ->_title($this->__('Manage Jobs'));
28
-
29
- $this->loadLayout();
30
- $this->renderLayout();
31
-
32
- // try {
33
- // $this->_title($this->__('Manage Jobs'));
34
- // return $this->_initAction()
35
- // ->_addContent(Mage::getSingleton('core/layout')->createBlock('strakertranslations_easytranslationplatform/adminhtml_job_grid'))
36
- // ->renderLayout();
37
- // } catch (Exception $e) {
38
- // Mage::getSingleton('core/session')->addError($this->__('Error occurred. Please contact service administrator.'));
39
- // $this->_redirect('adminhtml/dashboard');
40
- // }
41
- }
42
- public function copyAllAction(){
43
- $job = Mage::getModel('strakertranslations_easytranslationplatform/job')->load($this->getRequest()->getParam('job_id'));
44
-
45
- if (empty($job)){
46
- Mage::getSingleton('adminhtml/session')->addError('Job ID missing');
47
- $this->_redirect('*/adminhtml_job/');
48
- return;
49
- }
50
-
51
- if($job->applyTranslation()) {
52
- Mage::getSingleton('adminhtml/session')->addSuccess('Translation has been copied.');
53
- $this->_redirect('*/adminhtml_job/');
54
- return;
55
- } else {
56
- Mage::getSingleton('adminhtml/session')->addError('Error when copying translation.');
57
- $this->_redirect('*/adminhtml_job/');
58
- return;
59
- }
60
-
61
-
62
- }
63
- }
app/code/community/StrakerTranslations/EasyTranslationPlatform/controllers/Adminhtml/Straker/NewController.php CHANGED
@@ -15,6 +15,10 @@ Class StrakerTranslations_EasyTranslationPlatform_Adminhtml_Straker_NewControlle
15
return $this;
16
}
17
18
public function indexAction(){
19
$params = $this->getRequest()->getParams();
20
if (Mage::helper('strakertranslations_easytranslationplatform')->getAppKey() === false || Mage::helper('strakertranslations_easytranslationplatform')->getAccessToken() === false){
@@ -208,4 +212,20 @@ Class StrakerTranslations_EasyTranslationPlatform_Adminhtml_Straker_NewControlle
208
}
209
210
211
}
15
return $this;
16
}
17
18
+ public function accountAction(){
19
+ $this->_redirectUrl("http://myaccount.strakertranslations.com/");
20
+ }
21
+
22
public function indexAction(){
23
$params = $this->getRequest()->getParams();
24
if (Mage::helper('strakertranslations_easytranslationplatform')->getAppKey() === false || Mage::helper('strakertranslations_easytranslationplatform')->getAccessToken() === false){
212
}
213
214
215
+ public function resetStoreSettingsAction(){
216
+ $storeId = $this->getRequest()->getParam('store');
217
+ $helper = Mage::helper('strakertranslations_easytranslationplatform');
218
+ $session = Mage::getSingleton('adminhtml/session');
219
+
220
+ if($helper->getStoreSetup($storeId)){
221
+ $helper->saveStoreSetup($storeId, '', '', '');
222
+ $session->addSuccess($this->__('Language settings has been reset.'));
223
+ }
224
+ else{
225
+ $session->addError($this->__('Store code is not valid.'));
226
+ }
227
+ $this->_redirect('adminhtml/system_config/edit/section/straker');
228
+ return;
229
+ }
230
+
231
}
app/code/community/StrakerTranslations/EasyTranslationPlatform/etc/adminhtml.xml CHANGED
@@ -17,14 +17,19 @@
17
</new>
18
<job translate="title">
19
<title>Manage Jobs</title>
20
- <sort_order>0</sort_order>
21
<action>adminhtml/straker_job/index</action>
22
</job>
23
<settings translate="title">
24
<title>Settings</title>
25
<action>adminhtml/system_config/edit/section/straker</action>
26
- <sort_order>40</sort_order>
27
</settings>
28
</children>
29
</straker>
30
</menu>
17
</new>
18
<job translate="title">
19
<title>Manage Jobs</title>
20
+ <sort_order>10</sort_order>
21
<action>adminhtml/straker_job/index</action>
22
</job>
23
<settings translate="title">
24
<title>Settings</title>
25
<action>adminhtml/system_config/edit/section/straker</action>
26
+ <sort_order>20</sort_order>
27
</settings>
28
+ <account translate="title">
29
+ <title>Account</title>
30
+ <action>adminhtml/straker_new/account</action>
31
+ <sort_order>30</sort_order>
32
+ </account>
33
</children>
34
</straker>
35
</menu>
app/code/community/StrakerTranslations/EasyTranslationPlatform/etc/config.xml CHANGED
@@ -2,7 +2,7 @@
2
<config>
3
<modules>
4
<StrakerTranslations_EasyTranslationPlatform>
5
- <version>0.2.0</version>
6
</StrakerTranslations_EasyTranslationPlatform>
7
</modules>
8
<global>
@@ -111,15 +111,15 @@
111
<default>
112
<straker>
113
<api_url>
114
- <register>https://uat-magento-api.strakertranslations.com/v1/register</register>
115
- <languages>https://uat-magento-api.strakertranslations.com/v1/languages</languages>
116
- <translate>https://uat-magento-api.strakertranslations.com/v1/translate</translate>
117
- <quote>https://uat-magento-api.strakertranslations.com/v1/quote</quote>
118
- <payment>https://uat-magento-api.strakertranslations.com/v1/payment</payment>
119
- <countries>https://uat-magento-api.strakertranslations.com/v1/countries</countries>
120
- <payment>https://uat-magento-api.strakertranslations.com/v1/payment</payment>
121
- <payment_page>http://uat-api-myaccount.strakertranslations.com/o/?action=api.quote</payment_page>
122
- <support>https://uat-magento-api.strakertranslations.com/v1/support</support>
123
</api_url>
124
</straker>
125
</default>
2
<config>
3
<modules>
4
<StrakerTranslations_EasyTranslationPlatform>
5
+ <version>0.3.0</version>
6
</StrakerTranslations_EasyTranslationPlatform>
7
</modules>
8
<global>
111
<default>
112
<straker>
113
<api_url>
114
+ <register>https://magento-api.strakertranslations.com/v1/register</register>
115
+ <languages>https://magento-api.strakertranslations.com/v1/languages</languages>
116
+ <translate>https://magento-api.strakertranslations.com/v1/translate</translate>
117
+ <quote>https://magento-api.strakertranslations.com/v1/quote</quote>
118
+ <payment>https://magento-api.strakertranslations.com/v1/payment</payment>
119
+ <countries>https://magento-api.strakertranslations.com/v1/countries</countries>
120
+ <payment>https://magento-api.strakertranslations.com/v1/payment</payment>
121
+ <payment_page>https://myaccount.strakertranslations.com/o/?action=api.quote</payment_page>
122
+ <support>https://magento-api.strakertranslations.com/v1/support</support>
123
</api_url>
124
</straker>
125
</default>
app/code/community/StrakerTranslations/EasyTranslationPlatform/etc/system.xml CHANGED
@@ -32,14 +32,14 @@
32
<show_in_website>1</show_in_website>
33
<show_in_store>1</show_in_store>
34
</access_token>
35
- <application_key translate="label comment" >
36
- <label>Application Key</label>
37
- <frontend_type>text</frontend_type>
38
- <sort_order>20</sort_order>
39
- <show_in_default>1</show_in_default>
40
- <show_in_website>1</show_in_website>
41
- <show_in_store>1</show_in_store>
42
- </application_key>
43
<clear translate="label">
44
<label>Clear All Settings</label>
45
<frontend_type>button</frontend_type>
@@ -49,92 +49,101 @@
49
<show_in_website>1</show_in_website>
50
<show_in_store>1</show_in_store>
51
</clear>
52
- <backup translate="label">
53
- <label>Backup Product Data</label>
54
<frontend_type>button</frontend_type>
55
- <frontend_model>strakertranslations_easytranslationplatform/adminhtml_system_config_form_backupbutton</frontend_model>
56
<sort_order>40</sort_order>
57
<show_in_default>1</show_in_default>
58
<show_in_website>1</show_in_website>
59
<show_in_store>1</show_in_store>
60
- </backup>
61
- <restore translate="label">
62
- <label>Backup Product Data</label>
63
- <frontend_type>button</frontend_type>
64
- <frontend_model>strakertranslations_easytranslationplatform/adminhtml_system_config_form_restorebutton</frontend_model>
65
- <sort_order>50</sort_order>
66
- <show_in_default>1</show_in_default>
67
- <show_in_website>1</show_in_website>
68
- <show_in_store>1</show_in_store>
69
- </restore>
70
</fields>
71
</general>
72
- <api_url translate="label">
73
- <label>Api Url</label>
74
- <frontend_type>text</frontend_type>
75
- <sort_order>100</sort_order>
76
- <show_in_default>1</show_in_default>
77
- <show_in_website>1</show_in_website>
78
- <show_in_store>1</show_in_store>
79
- <fields>
80
- <register translate="label comment" >
81
- <label>Register</label>
82
- <frontend_type>text</frontend_type>
83
- <sort_order>10</sort_order>
84
- <show_in_default>1</show_in_default>
85
- <show_in_website>1</show_in_website>
86
- <show_in_store>1</show_in_store>
87
- </register>
88
- <languages translate="label comment" >
89
- <label>Languages</label>
90
- <frontend_type>text</frontend_type>
91
- <sort_order>30</sort_order>
92
- <show_in_default>1</show_in_default>
93
- <show_in_website>1</show_in_website>
94
- <show_in_store>1</show_in_store>
95
- </languages>
96
- <translate translate="label comment" >
97
- <label>Translate</label>
98
- <frontend_type>text</frontend_type>
99
- <sort_order>40</sort_order>
100
- <show_in_default>1</show_in_default>
101
- <show_in_website>1</show_in_website>
102
- <show_in_store>1</show_in_store>
103
- </translate>
104
- <countries translate="label comment" >
105
- <label>Countries</label>
106
- <frontend_type>text</frontend_type>
107
- <sort_order>20</sort_order>
108
- <show_in_default>1</show_in_default>
109
- <show_in_website>1</show_in_website>
110
- <show_in_store>1</show_in_store>
111
- </countries>
112
- <quote translate="label comment" >
113
- <label>Quote</label>
114
- <frontend_type>text</frontend_type>
115
- <sort_order>20</sort_order>
116
- <show_in_default>1</show_in_default>
117
- <show_in_website>1</show_in_website>
118
- <show_in_store>1</show_in_store>
119
- </quote>
120
- <payment translate="label comment" >
121
- <label>Payment</label>
122
- <frontend_type>text</frontend_type>
123
- <sort_order>50</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
- </payment>
128
- <payment_page translate="label comment" >
129
- <label>Payment Page</label>
130
- <frontend_type>text</frontend_type>
131
- <sort_order>50</sort_order>
132
- <show_in_default>1</show_in_default>
133
- <show_in_website>1</show_in_website>
134
- <show_in_store>1</show_in_store>
135
- </payment_page>
136
- </fields>
137
- </api_url>
138
</groups>
139
</straker>
140
</sections>
32
<show_in_website>1</show_in_website>
33
<show_in_store>1</show_in_store>
34
</access_token>
35
+ <!--<application_key translate="label comment" >-->
36
+ <!--<label>Application Key</label>-->
37
+ <!--<frontend_type>text</frontend_type>-->
38
+ <!--<sort_order>20</sort_order>-->
39
+ <!--<show_in_default>1</show_in_default>-->
40
+ <!--<show_in_website>1</show_in_website>-->
41
+ <!--<show_in_store>1</show_in_store>-->
42
+ <!--</application_key>-->
43
<clear translate="label">
44
<label>Clear All Settings</label>
45
<frontend_type>button</frontend_type>
49
<show_in_website>1</show_in_website>
50
<show_in_store>1</show_in_store>
51
</clear>
52
+ <store translate="label">
53
+ <label>Reset Language Settings for a Store</label>
54
<frontend_type>button</frontend_type>
55
+ <frontend_model>strakertranslations_easytranslationplatform/adminhtml_system_config_form_store</frontend_model>
56
<sort_order>40</sort_order>
57
<show_in_default>1</show_in_default>
58
<show_in_website>1</show_in_website>
59
<show_in_store>1</show_in_store>
60
+ </store>
61
+ <!--<backup translate="label">-->
62
+ <!--<label>Backup Product Data</label>-->
63
+ <!--<frontend_type>button</frontend_type>-->
64
+ <!--<frontend_model>strakertranslations_easytranslationplatform/adminhtml_system_config_form_backupbutton</frontend_model>-->
65
+ <!--<sort_order>40</sort_order>-->
66
+ <!--<show_in_default>1</show_in_default>-->
67
+ <!--<show_in_website>1</show_in_website>-->
68
+ <!--<show_in_store>1</show_in_store>-->
69
+ <!--</backup>-->
70
+ <!--<restore translate="label">-->
71
+ <!--<label>Backup Product Data</label>-->
72
+ <!--<frontend_type>button</frontend_type>-->
73
+ <!--<frontend_model>strakertranslations_easytranslationplatform/adminhtml_system_config_form_restorebutton</frontend_model>-->
74
+ <!--<sort_order>50</sort_order>-->
75
+ <!--<show_in_default>1</show_in_default>-->
76
+ <!--<show_in_website>1</show_in_website>-->
77
+ <!--<show_in_store>1</show_in_store>-->
78
+ <!--</restore>-->
79
</fields>
80
</general>
81
+ <!--<api_url translate="label">-->
82
+ <!--<label>Api Url</label>-->
83
+ <!--<frontend_type>text</frontend_type>-->
84
+ <!--<sort_order>100</sort_order>-->
85
+ <!--<show_in_default>1</show_in_default>-->
86
+ <!--<show_in_website>1</show_in_website>-->
87
+ <!--<show_in_store>1</show_in_store>-->
88
+ <!--<fields>-->
89
+ <!--<register translate="label comment" >-->
90
+ <!--<label>Register</label>-->
91
+ <!--<frontend_type>text</frontend_type>-->
92
+ <!--<sort_order>10</sort_order>-->
93
+ <!--<show_in_default>1</show_in_default>-->
94
+ <!--<show_in_website>1</show_in_website>-->
95
+ <!--<show_in_store>1</show_in_store>-->
96
+ <!--</register>-->
97
+ <!--<languages translate="label comment" >-->
98
+ <!--<label>Languages</label>-->
99
+ <!--<frontend_type>text</frontend_type>-->
100
+ <!--<sort_order>30</sort_order>-->
101
+ <!--<show_in_default>1</show_in_default>-->
102
+ <!--<show_in_website>1</show_in_website>-->
103
+ <!--<show_in_store>1</show_in_store>-->
104
+ <!--</languages>-->
105
+ <!--<translate translate="label comment" >-->
106
+ <!--<label>Translate</label>-->
107
+ <!--<frontend_type>text</frontend_type>-->
108
+ <!--<sort_order>40</sort_order>-->
109
+ <!--<show_in_default>1</show_in_default>-->
110
+ <!--<show_in_website>1</show_in_website>-->
111
+ <!--<show_in_store>1</show_in_store>-->
112
+ <!--</translate>-->
113
+ <!--<countries translate="label comment" >-->
114
+ <!--<label>Countries</label>-->
115
+ <!--<frontend_type>text</frontend_type>-->
116
+ <!--<sort_order>20</sort_order>-->
117
+ <!--<show_in_default>1</show_in_default>-->
118
+ <!--<show_in_website>1</show_in_website>-->
119
+ <!--<show_in_store>1</show_in_store>-->
120
+ <!--</countries>-->
121
+ <!--<quote translate="label comment" >-->
122
+ <!--<label>Quote</label>-->
123
+ <!--<frontend_type>text</frontend_type>-->
124
+ <!--<sort_order>20</sort_order>-->
125
+ <!--<show_in_default>1</show_in_default>-->
126
+ <!--<show_in_website>1</show_in_website>-->
127
+ <!--<show_in_store>1</show_in_store>-->
128
+ <!--</quote>-->
129
+ <!--<payment translate="label comment" >-->
130
+ <!--<label>Payment</label>-->
131
+ <!--<frontend_type>text</frontend_type>-->
132
+ <!--<sort_order>50</sort_order>-->
133
+ <!--<show_in_default>1</show_in_default>-->
134
+ <!--<show_in_website>1</show_in_website>-->
135
+ <!--<show_in_store>1</show_in_store>-->
136
+ <!--</payment>-->
137
+ <!--<payment_page translate="label comment" >-->
138
+ <!--<label>Payment Page</label>-->
139
+ <!--<frontend_type>text</frontend_type>-->
140
+ <!--<sort_order>50</sort_order>-->
141
+ <!--<show_in_default>1</show_in_default>-->
142
+ <!--<show_in_website>1</show_in_website>-->
143
+ <!--<show_in_store>1</show_in_store>-->
144
+ <!--</payment_page>-->
145
+ <!--</fields>-->
146
+ <!--</api_url>-->
147
</groups>
148
</straker>
149
</sections>
app/code/community/StrakerTranslations/EasyTranslationPlatform/sql/strakertranslations_easytranslationplatform_setup/mysql4-upgrade-0.2.0-0.3.0.php ADDED
@@ -0,0 +1,26 @@
1
+ <?php
2
+ /**
3
+ * Created by PhpStorm.
4
+ * User: stevenyang
5
+ * Date: 18/09/15
6
+ * Time: 9:46 AM
7
+ */
8
+ /* @var $installer Mage_Core_Model_Resource_Setup */
9
+ $installer = $this;
10
+
11
+ $installer->startSetup();
12
+
13
+ try {
14
+ $installer->run("
15
+
16
+ INSERT INTO `straker_job_status` (`status_id`, `status_name`)
17
+ VALUES
18
+ (5, 'PUBLISHED');
19
+
20
+
21
+ ");
22
+ } catch (Exception $e) {
23
+ Mage::logException($e);
24
+ }
25
+
26
+ $installer->endSetup();
app/design/adminhtml/default/straker/template/straker/system/config/store.phtml ADDED
@@ -0,0 +1,13 @@
1
+ <?php foreach (Mage::app()->getWebsites() as $website) { ?>
2
+ <div class="straker-store-settings-wrapper">
3
+ <?php foreach ($website->getGroups() as $group) {
4
+ $stores = $group->getStores();
5
+ foreach ($stores as $store) { ?>
6
+ <div class="straker-store-settings-row">
7
+ <label><?php echo $store->getName() ?></label>
8
+ <?php echo $this->getClearStoreButtonHtml($store) ?>
9
+ </div>
10
+ <?php } ?>
11
+ </div>
12
+ <?php }
13
+ }
js/straker/livepipe/livepipe.js DELETED
@@ -1,181 +0,0 @@
1
- /**
2
- * @author Ryan Johnson <http://syntacticx.com/>
3
- * @copyright 2008 PersonalGrid Corporation <http://personalgrid.com/>
4
- * @package LivePipe UI
5
- * @license MIT
6
- * @url http://livepipe.net/core
7
- * @require prototype.js
8
- */
9
-
10
- if(typeof(Control) == 'undefined')
11
- Control = {};
12
-
13
- var $proc = function(proc){
14
- return typeof(proc) == 'function' ? proc : function(){return proc};
15
- };
16
-
17
- var $value = function(value){
18
- return typeof(value) == 'function' ? value() : value;
19
- };
20
-
21
- Object.Event = {
22
- extend: function(object){
23
- object._objectEventSetup = function(event_name){
24
- this._observers = this._observers || {};
25
- this._observers[event_name] = this._observers[event_name] || [];
26
- };
27
- object.observe = function(event_name,observer){
28
- if(typeof(event_name) == 'string' && typeof(observer) != 'undefined'){
29
- this._objectEventSetup(event_name);
30
- if(!this._observers[event_name].include(observer))
31
- this._observers[event_name].push(observer);
32
- }else
33
- for(var e in event_name)
34
- this.observe(e,event_name[e]);
35
- };
36
- object.stopObserving = function(event_name,observer){
37
- this._objectEventSetup(event_name);
38
- if(event_name && observer)
39
- this._observers[event_name] = this._observers[event_name].without(observer);
40
- else if(event_name)
41
- this._observers[event_name] = [];
42
- else
43
- this._observers = {};
44
- };
45
- object.observeOnce = function(event_name,outer_observer){
46
- var inner_observer = function(){
47
- outer_observer.apply(this,arguments);
48
- this.stopObserving(event_name,inner_observer);
49
- }.bind(this);
50
- this._objectEventSetup(event_name);
51
- this._observers[event_name].push(inner_observer);
52
- };
53
- object.notify = function(event_name){
54
- this._objectEventSetup(event_name);
55
- var collected_return_values = [];
56
- var args = $A(arguments).slice(1);
57
- try{
58
- for(var i = 0; i < this._observers[event_name].length; ++i)
59
- collected_return_values.push(this._observers[event_name][i].apply(this,args) || null);
60
- }catch(e){
61
- if(e == $break)
62
- return false;
63
- else
64
- throw e;
65
- }
66
- return collected_return_values;
67
- };
68
- if(object.prototype){
69
- object.prototype._objectEventSetup = object._objectEventSetup;
70
- object.prototype.observe = object.observe;
71
- object.prototype.stopObserving = object.stopObserving;
72
- object.prototype.observeOnce = object.observeOnce;
73
- object.prototype.notify = function(event_name){
74
- if(object.notify){
75
- var args = $A(arguments).slice(1);
76
- args.unshift(this);
77
- args.unshift(event_name);
78
- object.notify.apply(object,args);
79
- }
80
- this._objectEventSetup(event_name);
81
- var args = $A(arguments).slice(1);
82
- var collected_return_values = [];
83
- try{
84
- if(this.options && this.options[event_name] && typeof(this.options[event_name]) == 'function')
85
- collected_return_values.push(this.options[event_name].apply(this,args) || null);
86
- var callbacks_copy = this._observers[event_name]; // since original array will be modified after observeOnce calls
87
- for(var i = 0; i < callbacks_copy.length; ++i)
88
- collected_return_values.push(callbacks_copy[i].apply(this,args) || null);
89
- }catch(e){
90
- if(e == $break)
91
- return false;
92
- else
93
- throw e;
94
- }
95
- return collected_return_values;
96
- };
97
- }
98
- }
99
- };
100
-
101
- /* Begin Core Extensions */
102
-
103
- //Element.observeOnce
104
- Element.addMethods({
105
- observeOnce: function(element,event_name,outer_callback){
106
- var inner_callback = function(){
107
- outer_callback.apply(this,arguments);
108
- Element.stopObserving(element,event_name,inner_callback);
109
- };
110
- Element.observe(element,event_name,inner_callback);
111
- }
112
- });
113
-
114
- //mouse:wheel
115
- (function(){
116
- function wheel(event){
117
- var delta, element, custom_event;
118
- // normalize the delta
119
- if (event.wheelDelta) { // IE & Opera
120
- delta = event.wheelDelta / 120;
121
- } else if (event.detail) { // W3C
122
- delta =- event.detail / 3;
123
- }
124
- if (!delta) { return; }
125
- element = Event.extend(event).target;
126
- element = Element.extend(element.nodeType === Node.TEXT_NODE ? element.parentNode : element);
127
- custom_event = element.fire('mouse:wheel',{ delta: delta });
128
- if (custom_event.stopped) {
129
- Event.stop(event);
130
- return false;
131
- }
132
- }
133
- document.observe('mousewheel',wheel);
134
- document.observe('DOMMouseScroll',wheel);
135
- })();
136
-
137
- /* End Core Extensions */
138
-
139
- //from PrototypeUI
140
- var IframeShim = Class.create({
141
- initialize: function() {
142
- this.element = new Element('iframe',{
143
- style: 'position:absolute;filter:progid:DXImageTransform.Microsoft.Alpha(opacity=0);display:none',
144
- src: 'javascript:void(0);',
145
- frameborder: 0
146
- });
147
- $(document.body).insert(this.element);
148
- },
149
- hide: function() {
150
- this.element.hide();
151
- return this;
152
- },
153
- show: function() {
154
- this.element.show();
155
- return this;
156
- },
157
- positionUnder: function(element) {
158
- var element = $(element);
159
- var offset = element.cumulativeOffset();
160
- var dimensions = element.getDimensions();
161
- this.element.setStyle({
162
- left: offset[0] + 'px',
163
- top: offset[1] + 'px',
164
- width: dimensions.width + 'px',
165
- height: dimensions.height + 'px',
166
- zIndex: element.getStyle('zIndex') - 1
167
- }).show();
168
- return this;
169
- },
170
- setBounds: function(bounds) {
171
- for(prop in bounds)
172
- bounds[prop] += 'px';
173
- this.element.setStyle(bounds);
174
- return this;
175
- },
176
- destroy: function() {
177
- if(this.element)
178
- this.element.remove();
179
- return this;
180
- }
181
- });
js/straker/livepipe/window.js DELETED
@@ -1,947 +0,0 @@
1
- /**
2
- * @author Ryan Johnson <http://syntacticx.com/>
3
- * @copyright 2008 PersonalGrid Corporation <http://personalgrid.com/>
4
- * @package LivePipe UI
5
- * @license MIT
6
- * @url http://livepipe.net/control/window
7
- * @require prototype.js, effects.js, draggable.js, resizable.js, livepipe.js
8
- */
9
-
10
- //adds onDraw and constrainToViewport option to draggable
11
- if(typeof(Draggable) != 'undefined'){
12
- //allows the point to be modified with an onDraw callback
13
- Draggable.prototype.draw = function(point) {
14
- var pos = Position.cumulativeOffset(this.element);
15
- if(this.options.ghosting) {
16
- var r = Position.realOffset(this.element);
17
- pos[0] += r[0] - Position.deltaX; pos[1] += r[1] - Position.deltaY;
18
- }
19
-
20
- var d = this.currentDelta();
21
- pos[0] -= d[0]; pos[1] -= d[1];
22
-
23
- if(this.options.scroll && (this.options.scroll != window && this._isScrollChild)) {
24
- pos[0] -= this.options.scroll.scrollLeft-this.originalScrollLeft;
25
- pos[1] -= this.options.scroll.scrollTop-this.originalScrollTop;
26
- }
27
-
28
- var p = [0,1].map(function(i){
29
- return (point[i]-pos[i]-this.offset[i])
30
- }.bind(this));
31
-
32
- if(this.options.snap) {
33
- if(typeof this.options.snap == 'function') {
34
- p = this.options.snap(p[0],p[1],this);
35
- } else {
36
- if(this.options.snap instanceof Array) {
37
- p = p.map( function(v, i) {return Math.round(v/this.options.snap[i])*this.options.snap[i] }.bind(this))
38
- } else {
39
- p = p.map( function(v) {return Math.round(v/this.options.snap)*this.options.snap }.bind(this))
40
- }
41
- }
42
- }
43
-
44
- if(this.options.onDraw)
45
- this.options.onDraw.bind(this)(p);
46
- else{
47
- var style = this.element.style;
48
- if(this.options.constrainToViewport){
49
- var viewport_dimensions = document.viewport.getDimensions();
50
- var container_dimensions = this.element.getDimensions();
51
- var margin_top = parseInt(this.element.getStyle('margin-top'));
52
- var margin_left = parseInt(this.element.getStyle('margin-left'));
53
- var boundary = [[
54
- 0 - margin_left,
55
- 0 - margin_top
56
- ],[
57
- (viewport_dimensions.width - container_dimensions.width) - margin_left,
58
- (viewport_dimensions.height - container_dimensions.height) - margin_top
59
- ]];
60
- if((!this.options.constraint) || (this.options.constraint=='horizontal')){
61
- if((p[0] >= boundary[0][0]) && (p[0] <= boundary[1][0]))
62
- this.element.style.left = p[0] + "px";
63
- else
64
- this.element.style.left = ((p[0] < boundary[0][0]) ? boundary[0][0] : boundary[1][0]) + "px";
65
- }
66
- if((!this.options.constraint) || (this.options.constraint=='vertical')){
67
- if((p[1] >= boundary[0][1] ) && (p[1] <= boundary[1][1]))
68
- this.element.style.top = p[1] + "px";
69
- else
70
- this.element.style.top = ((p[1] <= boundary[0][1]) ? boundary[0][1] : boundary[1][1]) + "px";
71
- }
72
- }else{
73
- if((!this.options.constraint) || (this.options.constraint=='horizontal'))
74
- style.left = p[0] + "px";
75
- if((!this.options.constraint) || (this.options.constraint=='vertical'))
76
- style.top = p[1] + "px";
77
- }
78
- if(style.visibility=="hidden")
79
- style.visibility = ""; // fix gecko rendering
80
- }
81
- };
82
- }
83
-
84
- if(typeof(Prototype) == "undefined")
85
- throw "Control.Window requires Prototype to be loaded.";
86
- if(typeof(IframeShim) == "undefined")
87
- throw "Control.Window requires IframeShim to be loaded.";
88
- if(typeof(Object.Event) == "undefined")
89
- throw "Control.Window requires Object.Event to be loaded.";
90
- /*
91
- known issues:
92
- - when iframe is clicked is does not gain focus
93
- - safari can't open multiple iframes properly
94
- - constrainToViewport: body must have no margin or padding for this to work properly
95
- - iframe will be mis positioned during fade in
96
- - document.viewport does not account for scrollbars (this will eventually be fixed in the prototype core)
97
- notes
98
- - setting constrainToViewport only works when the page is not scrollable
99
- - setting draggable: true will negate the effects of position: center
100
- */
101
- Control.Window = Class.create({
102
- initialize: function(container,options){
103
- Control.Window.windows.push(this);
104
-
105
- //attribute initialization
106
- this.container = false;
107
- this.isOpen = false;
108
- this.href = false;
109
- this.sourceContainer = false; //this is optionally the container that will open the window
110
- this.ajaxRequest = false;
111
- this.remoteContentLoaded = false; //this is set when the code to load the remote content is run, onRemoteContentLoaded is fired when the connection is closed
112
- this.numberInSequence = Control.Window.windows.length + 1; //only useful for the effect scoping
113
- this.indicator = false;
114
- this.effects = {
115
- fade: false,
116
- appear: false
117
- };
118
- this.indicatorEffects = {
119
- fade: false,
120
- appear: false
121
- };
122
-
123
- //options
124
- this.options = Object.extend({
125
- //lifecycle
126
- beforeOpen: Prototype.emptyFunction,
127
- afterOpen: Prototype.emptyFunction,
128
- beforeClose: Prototype.emptyFunction,
129
- afterClose: Prototype.emptyFunction,
130
- //dimensions and modes
131
- height: null,
132
- width: null,
133
- className: false,
134
- position: 'center', //'center', 'center_once', 'relative', [x,y], [function(){return x;},function(){return y;}]
135
- offsetLeft: 0, //available only for anchors opening the window, or windows set to position: hover
136
- offsetTop: 0, //""
137
- iframe: false, //if the window has an href, this will display the href as an iframe instead of requesting the url as an an Ajax.Request
138
- hover: false, //element object to hover over, or if "true" only available for windows with sourceContainer (an anchor or any element already on the page with an href attribute)
139
- indicator: false, //element to show or hide when ajax requests, images and iframes are loading
140
- closeOnClick: false, //does not work with hover,can be: true (click anywhere), 'container' (will refer to this.container), or element (a specific element)
141
- iframeshim: true, //whether or not to position an iFrameShim underneath the window
142
- //effects
143
- fade: false,
144
- fadeDuration: 0.75,
145
- //draggable
146
- draggable: false,
147
- onDrag: Prototype.emptyFunction,
148
- //resizable
149
- resizable: false,
150
- minHeight: false,
151
- minWidth: false,
152
- maxHeight: false,
153
- maxWidth: false,
154
- onResize: Prototype.emptyFunction,
155
- //draggable and resizable
156
- constrainToViewport: false,
157
- //ajax
158
- method: 'post',
159
- parameters: {},
160
- onComplete: Prototype.emptyFunction,
161
- onSuccess: Prototype.emptyFunction,
162
- onFailure: Prototype.emptyFunction,
163
- onException: Prototype.emptyFunction,
164
- //any element with an href (image,iframe,ajax) will call this after it is done loading
165
- onRemoteContentLoaded: Prototype.emptyFunction,
166
- insertRemoteContentAt: false //false will set this to this.container, can be string selector (first returned will be selected), or an Element that must be a child of this.container
167
- },options || {});
168
-
169
- //container setup
170
- this.indicator = this.options.indicator ? $(this.options.indicator) : false;
171
- if(container){
172
- if(typeof(container) == "string" && container.match(Control.Window.uriRegex))
173
- this.href = container;
174
- else{
175
- this.container = $(container);
176
- //need to create the container now for tooltips (or hover: element with no container already on the page)
177
- //second call made below will not create the container since the check is done inside createDefaultContainer()
178
- this.createDefaultContainer(container);
179
- //if an element with an href was passed in we use it to activate the window
180
- if(this.container && ((this.container.readAttribute('href') && this.container.readAttribute('href') != '') || (this.options.hover && this.options.hover !== true))){
181
- if(this.options.hover && this.options.hover !== true)
182
- this.sourceContainer = $(this.options.hover);
183
- else{
184
- this.sourceContainer = this.container;
185
- this.href = this.container.readAttribute('href');
186
- var rel = this.href.match(/^#(.+)#x2F;);
187
- if(rel && rel[1]){
188
- this.container = $(rel[1]);
189
- this.href = false;
190
- }else
191
- this.container = false;
192
- }
193
- //hover or click handling
194
- this.sourceContainerOpenHandler = function(event){
195
- this.open(event);
196
- event.stop();
197
- return false;
198
- }.bindAsEventListener(this);
199
- this.sourceContainerCloseHandler = function(event){
200
- this.close(event);
201
- }.bindAsEventListener(this);
202
- this.sourceContainerMouseMoveHandler = function(event){
203
- this.position(event);
204
- }.bindAsEventListener(this);
205
- if(this.options.hover){
206
- this.sourceContainer.observe('mouseenter',this.sourceContainerOpenHandler);
207
- this.sourceContainer.observe('mouseleave',this.sourceContainerCloseHandler);
208
- if(this.options.position == 'mouse')
209
- this.sourceContainer.observe('mousemove',this.sourceContainerMouseMoveHandler);
210
- }else
211
- this.sourceContainer.observe('click',this.sourceContainerOpenHandler);
212
- }
213
- }
214
- }
215
- this.createDefaultContainer(container);
216
- if(this.options.insertRemoteContentAt === false)
217
- this.options.insertRemoteContentAt = this.container;
218
- var styles = {
219
- margin: 0,
220
- position: 'absolute',
221
- zIndex: Control.Window.initialZIndexForWindow()
222
- };
223
- if(this.options.width)
224
- styles.width = $value(this.options.width) + 'px';
225
- if(this.options.height)
226
- styles.height = $value(this.options.height) + 'px';
227
- this.container.setStyle(styles);
228
- if(this.options.className)
229
- this.container.addClassName(this.options.className);
230
- this.positionHandler = this.position.bindAsEventListener(this);
231
- this.outOfBoundsPositionHandler = this.ensureInBounds.bindAsEventListener(this);
232
- this.bringToFrontHandler = this.bringToFront.bindAsEventListener(this);
233
- this.container.observe('mousedown',this.bringToFrontHandler);
234
- this.container.hide();
235
- this.closeHandler = this.close.bindAsEventListener(this);
236
- //iframeshim setup
237
- if(this.options.iframeshim){
238
- this.iFrameShim = new IframeShim();
239
- this.iFrameShim.hide();
240
- }
241
- //resizable support
242
- this.applyResizable();
243
- //draggable support
244
- this.applyDraggable();
245
-
246
- //makes sure the window can't go out of bounds
247
- Event.observe(window,'resize',this.outOfBoundsPositionHandler);
248
-
249
- this.notify('afterInitialize');
250
- },
251
- open: function(event){
252
- if(this.isOpen){
253
- this.bringToFront();
254
- return false;
255
- }
256
- if(this.notify('beforeOpen') === false)
257
- return false;
258
- //closeOnClick
259
- if(this.options.closeOnClick){
260
- if(this.options.closeOnClick === true)
261
- this.closeOnClickContainer = $(document.body);
262
- else if(this.options.closeOnClick == 'container')
263
- this.closeOnClickContainer = this.container;
264
- else if (this.options.closeOnClick == 'overlay'){
265
- Control.Overlay.load();
266
- this.closeOnClickContainer = Control.Overlay.container;
267
- }else
268
- this.closeOnClickContainer = $(this.options.closeOnClick);
269
- this.closeOnClickContainer.observe('click',this.closeHandler);
270
- }
271
- if(this.href && !this.options.iframe && !this.remoteContentLoaded){
272
- //link to image
273
- this.remoteContentLoaded = true;
274
- if(this.href.match(/\.(jpe?g|gif|png|tiff?)#x2F;i)){
275
- var img = new Element('img');
276
- img.observe('load',function(img){
277
- this.getRemoteContentInsertionTarget().insert(img);
278
- this.position();
279
- if(this.notify('onRemoteContentLoaded') !== false){
280
- if(this.options.indicator)
281
- this.hideIndicator();
282
- this.finishOpen();
283
- }
284
- }.bind(this,img));
285
- img.writeAttribute('src',this.href);
286
- }else{
287
- //if this is an ajax window it will only open if the request is successful
288
- if(!this.ajaxRequest){
289
- if(this.options.indicator)
290
- this.showIndicator();
291
- this.ajaxRequest = new Ajax.Request(this.href,{
292
- method: this.options.method,
293
- parameters: this.options.parameters,
294
- onComplete: function(request){
295
- this.notify('onComplete',request);
296
- this.ajaxRequest = false;
297
- }.bind(this),
298
- onSuccess: function(request){
299
- this.getRemoteContentInsertionTarget().insert(request.responseText);
300
- this.notify('onSuccess',request);
301
- if(this.notify('onRemoteContentLoaded') !== false){
302
- if(this.options.indicator)
303
- this.hideIndicator();
304
- this.finishOpen();
305
- }
306
- }.bind(this),
307
- onFailure: function(request){
308
- this.notify('onFailure',request);
309
- if(this.options.indicator)
310
- this.hideIndicator();
311
- }.bind(this),
312
- onException: function(request,e){
313
- this.notify('onException',request,e);
314
- if(this.options.indicator)
315
- this.hideIndicator();
316
- }.bind(this)
317
- });
318
- }
319
- }
320
- return true;
321
- }else if(this.options.iframe && !this.remoteContentLoaded){
322
- //iframe
323
- this.remoteContentLoaded = true;
324
- if(this.options.indicator)
325
- this.showIndicator();
326
- this.getRemoteContentInsertionTarget().insert(Control.Window.iframeTemplate.evaluate({
327
- href: this.href
328
- }));
329
- var iframe = this.container.down('iframe');
330
- iframe.onload = function(){
331
- this.notify('onRemoteContentLoaded');
332
- if(this.options.indicator)
333
- this.hideIndicator();
334
- iframe.onload = null;
335
- }.bind(this);
336
- }
337
- this.finishOpen(event);
338
- return true
339
- },
340
- close: function(event){ //event may or may not be present
341
- if(!this.isOpen || this.notify('beforeClose',event) === false)
342
- return false;
343
- if(this.options.closeOnClick)
344
- this.closeOnClickContainer.stopObserving('click',this.closeHandler);
345
- if(this.options.fade){
346
- this.effects.fade = new Effect.Fade(this.container,{
347
- queue: {
348
- position: 'front',
349
- scope: 'Control.Window' + this.numberInSequence
350
- },
351
- from: 1,
352
- to: 0,
353
- duration: this.options.fadeDuration / 2,
354
- afterFinish: function(){
355
- if(this.iFrameShim)
356
- this.iFrameShim.hide();
357
- this.isOpen = false;
358
- this.notify('afterClose');
359
- }.bind(this)
360
- });
361
- }else{
362
- this.container.hide();
363
- if(this.iFrameShim)
364
- this.iFrameShim.hide();
365
- }
366
- if(this.ajaxRequest)
367
- this.ajaxRequest.transport.abort();
368
- if(!(this.options.draggable || this.options.resizable) && this.options.position == 'center')
369
- Event.stopObserving(window,'resize',this.positionHandler);
370
- if(!this.options.draggable && this.options.position == 'center')
371
- Event.stopObserving(window,'scroll',this.positionHandler);
372
- if(this.options.indicator)
373
- this.hideIndicator();
374
- if(!this.options.fade){
375
- this.isOpen = false;
376
- this.notify('afterClose');
377
- }
378
- return true;
379
- },
380
- position: function(event){
381
- //this is up top for performance reasons
382
- if(this.options.position == 'mouse'){
383
- var xy = [Event.pointerX(event),Event.pointerY(event)];
384
- this.container.setStyle({
385
- top: xy[1] + $value(this.options.offsetTop) + 'px',
386
- left: xy[0] + $value(this.options.offsetLeft) + 'px'
387
- });
388
- return;
389
- }
390
- var container_dimensions = this.container.getDimensions();
391
- var viewport_dimensions = document.viewport.getDimensions();
392
- Position.prepare();
393
- var offset_left = (Position.deltaX + Math.floor((viewport_dimensions.width - container_dimensions.width) / 2));
394
- var offset_top = (Position.deltaY + ((viewport_dimensions.height > container_dimensions.height) ? Math.floor((viewport_dimensions.height - container_dimensions.height) / 2) : 0));
395
- if(this.options.position == 'center' || this.options.position == 'center_once'){
396
- this.container.setStyle({
397
- top: (container_dimensions.height <= viewport_dimensions.height) ? ((offset_top != null && offset_top > 0) ? offset_top : 0) + 'px' : 0,
398
- left: (container_dimensions.width <= viewport_dimensions.width) ? ((offset_left != null && offset_left > 0) ? offset_left : 0) + 'px' : 0
399
- });
400
- }else if(this.options.position == 'relative'){
401
- var xy = this.sourceContainer.cumulativeOffset();
402
- var top = xy[1] + $value(this.options.offsetTop);
403
- var left = xy[0] + $value(this.options.offsetLeft);
404
- this.container.setStyle({
405
- top: (container_dimensions.height <= viewport_dimensions.height) ? (this.options.constrainToViewport ? Math.max(0,Math.min(viewport_dimensions.height - (container_dimensions.height),top)) : top) + 'px' : 0,
406
- left: (container_dimensions.width <= viewport_dimensions.width) ? (this.options.constrainToViewport ? Math.max(0,Math.min(viewport_dimensions.width - (container_dimensions.width),left)) : left) + 'px' : 0
407
- });
408
- }else if(this.options.position.length){
409
- var top = $value(this.options.position[1]) + $value(this.options.offsetTop);
410
- var left = $value(this.options.position[0]) + $value(this.options.offsetLeft);
411
- this.container.setStyle({
412
- top: (container_dimensions.height <= viewport_dimensions.height) ? (this.options.constrainToViewport ? Math.max(0,Math.min(viewport_dimensions.height - (container_dimensions.height),top)) : top) + 'px' : 0,
413
- left: (container_dimensions.width <= viewport_dimensions.width) ? (this.options.constrainToViewport ? Math.max(0,Math.min(viewport_dimensions.width - (container_dimensions.width),left)) : left) + 'px' : 0
414
- });
415
- }
416
- if(this.iFrameShim)
417
- this.updateIFrameShimZIndex();
418
- },
419
- ensureInBounds: function(){
420
- if(!this.isOpen)
421
- return;
422
- var viewport_dimensions = document.viewport.getDimensions();
423
- var container_offset = this.container.cumulativeOffset();
424
- var container_dimensions = this.container.getDimensions();
425
- if(container_offset.left + container_dimensions.width > viewport_dimensions.width){
426
- this.container.setStyle({
427
- left: (Math.max(0,viewport_dimensions.width - container_dimensions.width)) + 'px'
428
- });
429
- }
430
- if(container_offset.top + container_dimensions.height > viewport_dimensions.height){
431
- this.container.setStyle({
432
- top: (Math.max(0,viewport_dimensions.height - container_dimensions.height)) + 'px'
433
- });
434
- }
435
- },
436
- bringToFront: function(){
437
- Control.Window.bringToFront(this);
438
- this.notify('bringToFront');
439
- },
440
- destroy: function(){
441
- this.container.stopObserving('mousedown',this.bringToFrontHandler);
442
- if(this.draggable){
443
- Draggables.removeObserver(this.container);
444
- this.draggable.handle.stopObserving('mousedown',this.bringToFrontHandler);
445
- this.draggable.destroy();
446
- }
447
- if(this.resizable){
448
- Resizables.removeObserver(this.container);
449
- this.resizable.handle.stopObserving('mousedown',this.bringToFrontHandler);
450
- this.resizable.destroy();
451
- }
452
- if(this.container && !this.sourceContainer)
453
- this.container.remove();
454
- if(this.sourceContainer){
455
- if(this.options.hover){
456
- this.sourceContainer.stopObserving('mouseenter',this.sourceContainerOpenHandler);
457
- this.sourceContainer.stopObserving('mouseleave',this.sourceContainerCloseHandler);
458
- if(this.options.position == 'mouse')
459
- this.sourceContainer.stopObserving('mousemove',this.sourceContainerMouseMoveHandler);
460
- }else
461
- this.sourceContainer.stopObserving('click',this.sourceContainerOpenHandler);
462
- }
463
- if(this.iFrameShim)
464
- this.iFrameShim.destroy();
465
- Event.stopObserving(window,'resize',this.outOfBoundsPositionHandler);
466
- Control.Window.windows = Control.Window.windows.without(this);
467
- this.notify('afterDestroy');
468
- },
469
- //private
470
- applyResizable: function(){
471
- if(this.options.resizable){
472
- if(typeof(Resizable) == "undefined")
473
- throw "Control.Window requires resizable.js to be loaded.";
474
- var resizable_handle = null;
475
- if(this.options.resizable === true){
476
- resizable_handle = new Element('div',{
477
- className: 'resizable_handle'
478
- });
479
- this.container.insert(resizable_handle);
480
- }else
481
- resizable_handle = $(this.options.resziable);
482
- this.resizable = new Resizable(this.container,{
483
- handle: resizable_handle,
484
- minHeight: this.options.minHeight,
485
- minWidth: this.options.minWidth,
486
- maxHeight: this.options.constrainToViewport ? function(element){
487
- //viewport height - top - total border height
488
- return (document.viewport.getDimensions().height - parseInt(element.style.top || 0)) - (element.getHeight() - parseInt(element.style.height || 0));
489
- } : this.options.maxHeight,
490
- maxWidth: this.options.constrainToViewport ? function(element){
491
- //viewport width - left - total border width
492
- return (document.viewport.getDimensions().width - parseInt(element.style.left || 0)) - (element.getWidth() - parseInt(element.style.width || 0));
493
- } : this.options.maxWidth
494
- });
495
- this.resizable.handle.observe('mousedown',this.bringToFrontHandler);
496
- Resizables.addObserver(new Control.Window.LayoutUpdateObserver(this,function(){
497
- if(this.iFrameShim)
498
- this.updateIFrameShimZIndex();
499
- this.notify('onResize');
500
- }.bind(this)));
501
- }
502
- },
503
- applyDraggable: function(){
504
- if(this.options.draggable){
505
- if(typeof(Draggables) == "undefined")
506
- throw "Control.Window requires dragdrop.js to be loaded.";
507
- var draggable_handle = null;
508
- if(this.options.draggable === true){
509
- draggable_handle = new Element('div',{
510
- className: 'draggable_handle'
511
- });
512
- this.container.insert(draggable_handle);
513
- }else
514
- draggable_handle = $(this.options.draggable);
515
- this.draggable = new Draggable(this.container,{
516
- handle: draggable_handle,
517
- constrainToViewport: this.options.constrainToViewport,
518
- zindex: this.container.getStyle('z-index'),
519
- starteffect: function(){
520
- if(Prototype.Browser.IE){
521
- this.old_onselectstart = document.onselectstart;
522
- document.onselectstart = function(){
523
- return false;
524
- };
525
- }
526
- }.bind(this),
527
- endeffect: function(){
528
- document.onselectstart = this.old_onselectstart;
529
- }.bind(this)
530
- });
531
- this.draggable.handle.observe('mousedown',this.bringToFrontHandler);
532
- Draggables.addObserver(new Control.Window.LayoutUpdateObserver(this,function(){
533
- if(this.iFrameShim)
534
- this.updateIFrameShimZIndex();
535
- this.notify('onDrag');
536
- }.bind(this)));
537
- }
538
- },
539
- createDefaultContainer: function(container){
540
- if(!this.container){
541
- //no container passed or found, create it
542
- this.container = new Element('div',{
543
- id: 'control_window_' + this.numberInSequence
544
- });
545
- $(document.body).insert(this.container);
546
- if(typeof(container) == "string" && $(container) == null && !container.match(/^#(.+)#x2F;) && !container.match(Control.Window.uriRegex))
547
- this.container.update(container);
548
- }
549
- },
550
- finishOpen: function(event){
551
- this.bringToFront();
552
- if(this.options.fade){
553
- if(typeof(Effect) == "undefined")
554
- throw "Control.Window requires effects.js to be loaded."
555
- if(this.effects.fade)
556
- this.effects.fade.cancel();
557
- this.effects.appear = new Effect.Appear(this.container,{
558
- queue: {
559
- position: 'end',
560
- scope: 'Control.Window.' + this.numberInSequence
561
- },
562
- from: 0,
563
- to: 1,
564
- duration: this.options.fadeDuration / 2,
565
- afterFinish: function(){
566
- if(this.iFrameShim)
567
- this.updateIFrameShimZIndex();
568
- this.isOpen = true;
569
- this.notify('afterOpen');
570
- }.bind(this)
571
- });
572
- }else
573
- this.container.show();
574
- this.position(event);
575
- if(!(this.options.draggable || this.options.resizable) && this.options.position == 'center')
576
- Event.observe(window,'resize',this.positionHandler,false);
577
- if(!this.options.draggable && this.options.position == 'center')
578
- Event.observe(window,'scroll',this.positionHandler,false);
579
- if(!this.options.fade){
580
- this.isOpen = true;
581
- this.notify('afterOpen');
582
- }
583
- return true;
584
- },
585
- showIndicator: function(){
586
- this.showIndicatorTimeout = window.setTimeout(function(){
587
- if(this.options.fade){
588
- this.indicatorEffects.appear = new Effect.Appear(this.indicator,{
589
- queue: {
590
- position: 'front',
591
- scope: 'Control.Window.indicator.' + this.numberInSequence
592
- },
593
- from: 0,
594
- to: 1,
595
- duration: this.options.fadeDuration / 2
596
- });
597
- }else
598
- this.indicator.show();
599
- }.bind(this),Control.Window.indicatorTimeout);
600
- },
601
- hideIndicator: function(){
602
- if(this.showIndicatorTimeout)
603
- window.clearTimeout(this.showIndicatorTimeout);
604
- this.indicator.hide();
605
- },
606
- getRemoteContentInsertionTarget: function(){
607
- return typeof(this.options.insertRemoteContentAt) == "string" ? this.container.down(this.options.insertRemoteContentAt) : $(this.options.insertRemoteContentAt);
608
- },
609
- updateIFrameShimZIndex: function(){
610
- if(this.iFrameShim)
611
- this.iFrameShim.positionUnder(this.container);
612
- }
613
- });
614
- //class methods
615
- Object.extend(Control.Window,{
616
- windows: [],
617
- baseZIndex: 9999,
618
- indicatorTimeout: 250,
619
- iframeTemplate: new Template('<iframe src="#{href}" width="100%" height="100%" frameborder="0"></iframe>'),
620
- uriRegex: /^(\/|\#|https?\:\/\/|[\w]+\/)/,
621
- bringToFront: function(w){
622
- Control.Window.windows = Control.Window.windows.without(w);
623
- Control.Window.windows.push(w);
624
- Control.Window.windows.each(function(w,i){
625
- var z_index = Control.Window.baseZIndex + i;
626
- w.container.setStyle({
627
- zIndex: z_index
628
- });
629
- if(w.isOpen){
630
- if(w.iFrameShim)
631
- w.updateIFrameShimZIndex();
632
- }
633
- if(w.options.draggable)
634
- w.draggable.options.zindex = z_index;
635
- });
636
- },
637
- open: function(container,options){
638
- var w = new Control.Window(container,options);
639
- w.open();
640
- return w;
641
- },
642
- //protected
643
- initialZIndexForWindow: function(w){
644
- return Control.Window.baseZIndex + (Control.Window.windows.length - 1);
645
- }
646
- });
647
- Object.Event.extend(Control.Window);
648
-
649
- //this is the observer for both Resizables and Draggables
650
- Control.Window.LayoutUpdateObserver = Class.create({
651
- initialize: function(w,observer){
652
- this.w = w;
653
- this.element = $(w.container);
654
- this.observer = observer;
655
- },
656
- onStart: Prototype.emptyFunction,
657
- onEnd: function(event_name,instance){
658
- if(instance.element == this.element && this.iFrameShim)
659
- this.w.updateIFrameShimZIndex();
660
- },
661
- onResize: function(event_name,instance){
662
- if(instance.element == this.element)
663
- this.observer(this.element);
664
- },
665
- onDrag: function(event_name,instance){
666
- if(instance.element == this.element)
667
- this.observer(this.element);
668
- }
669
- });
670
-
671
- //overlay for Control.Modal
672
- Control.Overlay = {
673
- id: 'control_overlay',
674
- loaded: false,
675
- container: false,
676
- lastOpacity: 0,
677
- getStyles: function() {
678
- return {
679
- position: 'fixed',
680
- top: 0,
681
- left: 0,
682
- width: '100%',
683
- height: '100%',
684
- zIndex: Control.Window.baseZIndex - 1
685
- };
686
- },
687
- getIeStyles: function() {
688
- return {
689
- position: 'absolute',
690
- top: 0,
691
- left: 0,
692
- zIndex: Control.Window.baseZIndex - 1
693
- };
694
- },
695
- effects: {
696
- fade: false,
697
- appear: false
698
- },
699
- load: function(){
700
- if(Control.Overlay.loaded)
701
- return false;
702
- Control.Overlay.loaded = true;
703
- Control.Overlay.container = new Element('div',{
704
- id: Control.Overlay.id
705
- });
706
- $(document.body).insert(Control.Overlay.container);
707
- if(Prototype.Browser.IE){
708
- Control.Overlay.container.setStyle(Control.Overlay.getIeStyles());
709
- Event.observe(window,'scroll',Control.Overlay.positionOverlay);
710
- Event.observe(window,'resize',Control.Overlay.positionOverlay);
711
- Control.Overlay.observe('beforeShow',Control.Overlay.positionOverlay);
712
- }else
713
- Control.Overlay.container.setStyle(Control.Overlay.getStyles());
714
- Control.Overlay.iFrameShim = new IframeShim();
715
- Control.Overlay.iFrameShim.hide();
716
- Event.observe(window,'resize',Control.Overlay.positionIFrameShim);
717
- Control.Overlay.container.hide();
718
- return true;
719
- },
720
- unload: function(){
721
- if(!Control.Overlay.loaded)
722
- return false;
723
- Event.stopObserving(window,'resize',Control.Overlay.positionOverlay);
724
- Control.Overlay.stopObserving('beforeShow',Control.Overlay.positionOverlay);
725
- Event.stopObserving(window,'resize',Control.Overlay.positionIFrameShim);
726
- Control.Overlay.iFrameShim.destroy();
727
- Control.Overlay.container.remove();
728
- Control.Overlay.loaded = false;
729
- return true;
730
- },
731
- show: function(opacity,fade){
732
- if(Control.Overlay.notify('beforeShow') === false)
733
- return false;
734
- Control.Overlay.lastOpacity = opacity;
735
- Control.Overlay.positionIFrameShim();
736
- Control.Overlay.iFrameShim.show();
737
- if(fade){
738
- if(typeof(Effect) == "undefined")
739
- throw "Control.Window requires effects.js to be loaded."
740
- if(Control.Overlay.effects.fade)
741
- Control.Overlay.effects.fade.cancel();
742
- Control.Overlay.effects.appear = new Effect.Appear(Control.Overlay.container,{
743
- queue: {
744
- position: 'end',
745
- scope: 'Control.Overlay'
746
- },
747
- afterFinish: function(){
748
- Control.Overlay.notify('afterShow');
749
- },
750
- from: 0,
751
- to: Control.Overlay.lastOpacity,
752
- duration: (fade === true ? 0.75 : fade) / 2
753
- });
754
- }else{
755
- Control.Overlay.container.setStyle({
756
- opacity: opacity || 1
757
- });
758
- Control.Overlay.container.show();
759
- Control.Overlay.notify('afterShow');
760
- }
761
- return true;
762
- },
763
- hide: function(fade){
764
- if(Control.Overlay.notify('beforeHide') === false)
765
- return false;
766
- if(Control.Overlay.effects.appear)
767
- Control.Overlay.effects.appear.cancel();
768
- Control.Overlay.iFrameShim.hide();
769
- if(fade){
770
- Control.Overlay.effects.fade = new Effect.Fade(Control.Overlay.container,{
771
- queue: {
772
- position: 'front',
773
- scope: 'Control.Overlay'
774
- },
775
- afterFinish: function(){
776
- Control.Overlay.notify('afterHide');
777
- },
778
- from: Control.Overlay.lastOpacity,
779
- to: 0,
780
- duration: (fade === true ? 0.75 : fade) / 2
781
- });
782
- }else{
783
- Control.Overlay.container.hide();
784
- Control.Overlay.notify('afterHide');
785
- }
786
- return true;
787
- },
788
- positionIFrameShim: function(){
789
- if(Control.Overlay.container.visible())
790
- Control.Overlay.iFrameShim.positionUnder(Control.Overlay.container);
791
- },
792
- //IE only
793
- positionOverlay: function(){
794
- Control.Overlay.container.setStyle({
795
- width: document.body.clientWidth + 'px',
796
- height: document.body.clientHeight + 'px'
797
- });
798
- }
799
- };
800
- Object.Event.extend(Control.Overlay);
801
-
802
- Control.ToolTip = Class.create(Control.Window,{
803
- initialize: function($super,container,tooltip,options){
804
- $super(tooltip,Object.extend(Object.extend(Object.clone(Control.ToolTip.defaultOptions),options || {}),{
805
- position: 'mouse',
806
- hover: container
807
- }));
808
- }
809
- });
810
- Object.extend(Control.ToolTip,{
811
- defaultOptions: {
812
- offsetLeft: 10
813
- }
814
- });
815
-
816
- Control.Modal = Class.create(Control.Window,{
817
- initialize: function($super,container,options){
818
- Control.Modal.InstanceMethods.beforeInitialize.bind(this)();
819
- $super(container,Object.extend(Object.clone(Control.Modal.defaultOptions),options || {}));
820
- },
821
- closeWithoutOverlay: function(){
822
- this.keepOverlay = true;
823
- this.close();
824
- }
825
- });
826
- Object.extend(Control.Modal,{
827
- defaultOptions: {
828
- overlayOpacity: 0.5,
829
- closeOnClick: 'overlay'
830
- },
831
- current: false,
832
- open: function(container,options){
833
- var modal = new Control.Modal(container,options);
834
- modal.open();
835
- return modal;
836
- },
837
- close: function(){
838
- if(Control.Modal.current)
839
- Control.Modal.current.close();
840
- },
841
- InstanceMethods: {
842
- beforeInitialize: function(){
843
- Control.Overlay.load();
844
- this.observe('beforeOpen',Control.Modal.Observers.beforeOpen.bind(this));
845
- this.observe('afterOpen',Control.Modal.Observers.afterOpen.bind(this));
846
- this.observe('afterClose',Control.Modal.Observers.afterClose.bind(this));
847
- }
848
- },
849
- Observers: {
850
- beforeOpen: function(){
851
- Control.Window.windows.without(this).each(function(w){
852
- if(w.closeWithoutOverlay && w.isOpen){
853
- w.closeWithoutOverlay();
854
- }else{
855
- w.close();
856
- }
857
- });
858
- if(!Control.Overlay.overlayFinishedOpening){
859
- Control.Overlay.observeOnce('afterShow',function(){
860
- Control.Overlay.overlayFinishedOpening = true;
861
- this.open();
862
- }.bind(this));
863
- Control.Overlay.show(this.options.overlayOpacity,this.options.fade ? this.options.fadeDuration : false);
864
- throw $break;
865
- }
866
- },
867
- afterOpen: function(){
868
- Control.Overlay.show(this.options.overlayOpacity);
869
- Control.Overlay.overlayFinishedOpening = true;
870
- Control.Modal.current = this;
871
- },
872
- afterClose: function(){
873
- if(!this.keepOverlay){
874
- Control.Overlay.hide(this.options.fade ? this.options.fadeDuration : false);
875
- Control.Overlay.overlayFinishedOpening = false;
876
- }
877
- this.keepOverlay = false;
878
- Control.Modal.current = false;
879
- }
880
- }
881
- });
882
-
883
- Control.LightBox = Class.create(Control.Window,{
884
- initialize: function($super,container,options){
885
- this.allImagesLoaded = false;
886
- if(options.modal){
887
- var options = Object.extend(Object.clone(Control.LightBox.defaultOptions),options || {});
888
- options = Object.extend(Object.clone(Control.Modal.defaultOptions),options);
889
- options = Control.Modal.InstanceMethods.beforeInitialize.bind(this)(options);
890
- $super(container,options);
891
- }else
892
- $super(container,Object.extend(Object.clone(Control.LightBox.defaultOptions),options || {}));
893
- this.hasRemoteContent = this.href && !this.options.iframe;
894
- if(this.hasRemoteContent)
895
- this.observe('onRemoteContentLoaded',Control.LightBox.Observers.onRemoteContentLoaded.bind(this));
896
- else
897
- this.applyImageObservers();
898
- this.observe('beforeOpen',Control.LightBox.Observers.beforeOpen.bind(this));
899
- },
900
- applyImageObservers:function(){
901
- var images = this.getImages();
902
- this.numberImagesToLoad = images.length;
903
- this.numberofImagesLoaded = 0;
904
- images.each(function(image){
905
- image.observe('load',function(image){
906
- ++this.numberofImagesLoaded;
907
- if(this.numberImagesToLoad == this.numberofImagesLoaded){
908
- this.allImagesLoaded = true;
909
- this.onAllImagesLoaded();
910
- }
911
- }.bind(this,image));
912
- image.hide();
913
- }.bind(this));
914
- },
915
- onAllImagesLoaded: function(){
916
- this.getImages().each(function(image){
917
- this.showImage(image);
918
- }.bind(this));
919
- if(this.hasRemoteContent){
920
- if(this.options.indicator)
921
- this.hideIndicator();
922
- this.finishOpen();
923
- }else
924
- this.open();
925
- },
926
- getImages: function(){
927
- return this.container.select(Control.LightBox.imageSelector);
928
- },
929
- showImage: function(image){
930
- image.show();
931
- }
932
- });
933
- Object.extend(Control.LightBox,{
934
- imageSelector: 'img',
935
- defaultOptions: {},
936
- Observers: {
937
- beforeOpen: function(){
938
- if(!this.hasRemoteContent && !this.allImagesLoaded)
939
- throw $break;
940
- },
941
- onRemoteContentLoaded: function(){
942
- this.applyImageObservers();
943
- if(!this.allImagesLoaded)
944
- throw $break;
945
- }
946
- }
947
- });