Version Notes
First release of the extension
Download this release
Release Info
Developer | Abhishek Dixit |
Extension | Srdt_Banner_Slider |
Version | 1.0.0 |
Comparing to | |
See all releases |
Version 1.0.0
- app/code/local/Srdt/Slider/Block/Adminhtml/Slider.php +15 -0
- app/code/local/Srdt/Slider/Block/Adminhtml/Slider/Edit.php +40 -0
- app/code/local/Srdt/Slider/Block/Adminhtml/Slider/Edit/Form.php +25 -0
- app/code/local/Srdt/Slider/Block/Adminhtml/Slider/Edit/Tab/Form.php +157 -0
- app/code/local/Srdt/Slider/Block/Adminhtml/Slider/Edit/Tabs.php +28 -0
- app/code/local/Srdt/Slider/Block/Adminhtml/Slider/Grid.php +122 -0
- app/code/local/Srdt/Slider/Block/Banner.php +35 -0
- app/code/local/Srdt/Slider/Helper/Data.php +67 -0
- app/code/local/Srdt/Slider/Model/Resource/Slider.php +13 -0
- app/code/local/Srdt/Slider/Model/Resource/Slider/Collection.php +7 -0
- app/code/local/Srdt/Slider/Model/Slider.php +8 -0
- app/code/local/Srdt/Slider/controllers/Adminhtml/IndexController.php +189 -0
- app/code/local/Srdt/Slider/etc/adminhtml.xml +16 -0
- app/code/local/Srdt/Slider/etc/config.xml +81 -0
- app/code/local/Srdt/Slider/sql/slider_setup/install-1.0.0.php +19 -0
- app/design/frontend/base/default/template/banner/slider.phtml +61 -0
- app/etc/modules/Srdt_Slider.xml +9 -0
- package.xml +18 -0
- skin/frontend/base/default/css/srdt/jquery.bxslider.css +210 -0
- skin/frontend/base/default/images/srdt/bx_loader.gif +0 -0
- skin/frontend/base/default/images/srdt/controls.png +0 -0
- skin/frontend/base/default/js/srdt/jquery.bxslider.js +1343 -0
- skin/frontend/base/default/js/srdt/jquery.bxslider.min.js +10 -0
- skin/frontend/base/default/js/srdt/jquery.easing.1.3.js +205 -0
- skin/frontend/base/default/js/srdt/jquery.fitvids.js +80 -0
app/code/local/Srdt/Slider/Block/Adminhtml/Slider.php
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Srdt_Slider_Block_Adminhtml_Slider extends Mage_Adminhtml_Block_Widget_Grid_Container
|
4 |
+
{
|
5 |
+
public function __construct()
|
6 |
+
{
|
7 |
+
|
8 |
+
$this->_blockGroup = 'srdt_slider';
|
9 |
+
$this->_controller = 'adminhtml_slider';
|
10 |
+
$this->_headerText = Mage::helper('srdt_slider')->__('Srdt Banner Slider');
|
11 |
+
|
12 |
+
parent::__construct();
|
13 |
+
|
14 |
+
}
|
15 |
+
}
|
app/code/local/Srdt/Slider/Block/Adminhtml/Slider/Edit.php
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Srdt_Slider_Block_Adminhtml_Slider_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
|
4 |
+
{
|
5 |
+
public function __construct()
|
6 |
+
{
|
7 |
+
|
8 |
+
$this->_objectId = 'id';
|
9 |
+
$this->_blockGroup = 'srdt_slider';
|
10 |
+
$this->_controller = 'adminhtml_slider';
|
11 |
+
parent::__construct();
|
12 |
+
$this->_updateButton('save', 'label', Mage::helper('srdt_slider')->__('Save Banner'));
|
13 |
+
$this->_updateButton('delete', 'label', Mage::helper('srdt_slider')->__('Delete Banner'));
|
14 |
+
|
15 |
+
$this->_addButton('saveandcontinue', array(
|
16 |
+
'label' => Mage::helper('adminhtml')->__('Save And Continue Edit'),
|
17 |
+
'onclick' => 'saveAndContinueEdit()',
|
18 |
+
'class' => 'save',
|
19 |
+
), -100);
|
20 |
+
|
21 |
+
$this->_formScripts[] = "
|
22 |
+
|
23 |
+
function saveAndContinueEdit(){
|
24 |
+
editForm.submit($('edit_form').action+'back/edit/');
|
25 |
+
}
|
26 |
+
";
|
27 |
+
// return $this;
|
28 |
+
}
|
29 |
+
|
30 |
+
public function getHeaderText()
|
31 |
+
{
|
32 |
+
if( Mage::registry('banner_data') && Mage::registry('banner_data')->getId() ) {
|
33 |
+
return Mage::helper('srdt_slider')->__("Edit Banner '%s'", $this->htmlEscape(Mage::registry('banner_data')->getBannerTitle()));
|
34 |
+
} else {
|
35 |
+
return Mage::helper('srdt_slider')->__('Add Banner Slider');
|
36 |
+
}
|
37 |
+
|
38 |
+
}
|
39 |
+
|
40 |
+
}
|
app/code/local/Srdt/Slider/Block/Adminhtml/Slider/Edit/Form.php
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Srdt_Slider_Block_Adminhtml_Slider_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
|
4 |
+
{
|
5 |
+
protected function _prepareForm()
|
6 |
+
{
|
7 |
+
// echo "prepare form";
|
8 |
+
// exit;
|
9 |
+
$form = new Varien_Data_Form(array(
|
10 |
+
'id' => 'edit_form',
|
11 |
+
|
12 |
+
'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))),
|
13 |
+
|
14 |
+
'method' => 'post',
|
15 |
+
|
16 |
+
'enctype' => 'multipart/form-data'
|
17 |
+
|
18 |
+
//print_r($from);
|
19 |
+
));
|
20 |
+
|
21 |
+
$form->setUseContainer(true);
|
22 |
+
$this->setForm($form);
|
23 |
+
return parent::_prepareForm();
|
24 |
+
}
|
25 |
+
}
|
app/code/local/Srdt/Slider/Block/Adminhtml/Slider/Edit/Tab/Form.php
ADDED
@@ -0,0 +1,157 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Srdt_Slider_Block_Adminhtml_Slider_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form {
|
4 |
+
|
5 |
+
|
6 |
+
protected function _prepareForm() {
|
7 |
+
|
8 |
+
$form = new Varien_Data_Form();
|
9 |
+
$this->setForm($form);
|
10 |
+
$dataObj = new Varien_Object();
|
11 |
+
if (Mage::getSingleton('adminhtml/session')->getBannerData()) {
|
12 |
+
$data = Mage::getSingleton('adminhtml/session')->getBannerData();
|
13 |
+
Mage::getSingleton('adminhtml/session')->setBannerData(null);
|
14 |
+
} elseif (Mage::registry('banner_data'))
|
15 |
+
$data = Mage::registry('banner_data')->getData();
|
16 |
+
if (isset($data)) {
|
17 |
+
$dataObj->addData($data);
|
18 |
+
}
|
19 |
+
$fieldset = $form->addFieldset('banner_form', array('legend' => Mage::helper('srdt_slider')->__('Banner information')));
|
20 |
+
$data = $dataObj->getData();
|
21 |
+
$inStore = $this->getRequest()->getParam('store');
|
22 |
+
$fieldset->addField('banner_id', 'hidden', array(
|
23 |
+
'required' => false,
|
24 |
+
'name' => 'banner_id',
|
25 |
+
|
26 |
+
));
|
27 |
+
$fieldset->addField('banner_title', 'text', array(
|
28 |
+
'label' => Mage::helper('srdt_slider')->__('Banner Title'),
|
29 |
+
'required' => true,
|
30 |
+
'name' => 'banner_title',
|
31 |
+
));
|
32 |
+
|
33 |
+
$fieldset->addField('banner_type', 'select', array(
|
34 |
+
'label' => Mage::helper('srdt_slider')->__('Banner Type'),
|
35 |
+
'required' => true,
|
36 |
+
'class'=>'required-entry validate-select',
|
37 |
+
'name' => 'banner_type',
|
38 |
+
//'id' => 'my_select',
|
39 |
+
'onchange' => 'checkBannerType(this.value)',
|
40 |
+
'values' => array(
|
41 |
+
|
42 |
+
array(
|
43 |
+
'value' => '',
|
44 |
+
'label' => Mage::helper('srdt_slider')->__('Select Banner Type'),
|
45 |
+
),
|
46 |
+
array(
|
47 |
+
'value' => 2,
|
48 |
+
'label' => Mage::helper('srdt_slider')->__('Images'),
|
49 |
+
),
|
50 |
+
array(
|
51 |
+
'value' => 1,
|
52 |
+
'label' => Mage::helper('srdt_slider')->__('Video'),
|
53 |
+
),
|
54 |
+
|
55 |
+
),
|
56 |
+
));
|
57 |
+
if (isset($data['banner_image']) && $data['banner_image']) {
|
58 |
+
$data['banner_image'] = 'bannerslider' . '/' .$data['banner_image'];
|
59 |
+
}
|
60 |
+
$fieldset->addField('banner_image', 'image', array(
|
61 |
+
'label' => Mage::helper('srdt_slider')->__('Banner Image'),
|
62 |
+
'required' => false,
|
63 |
+
//'class'=>'required-entry',
|
64 |
+
'name' => 'banner_image',
|
65 |
+
));
|
66 |
+
|
67 |
+
$fieldset->addField('banner_caption', 'text', array(
|
68 |
+
'label' => Mage::helper('srdt_slider')->__('Banner Caption'),
|
69 |
+
'required' => true,
|
70 |
+
'name' => 'banner_caption',
|
71 |
+
));
|
72 |
+
$fieldset->addField('banner_url', 'text', array(
|
73 |
+
'label' => Mage::helper('srdt_slider')->__('Redirect Url'),
|
74 |
+
'required' => true,
|
75 |
+
'name' => 'banner_url',
|
76 |
+
));
|
77 |
+
$fieldset->addField('youtube_url', 'text', array(
|
78 |
+
'label' => Mage::helper('srdt_slider')->__('Youtube Url'),
|
79 |
+
'required' => true,
|
80 |
+
'name' => 'youtube_url',
|
81 |
+
));
|
82 |
+
|
83 |
+
|
84 |
+
$fieldset->addField('banner_status', 'select', array(
|
85 |
+
'label' => Mage::helper('srdt_slider')->__('Banner Status'),
|
86 |
+
'required' => true,
|
87 |
+
'class'=>'required-entry validate-select',
|
88 |
+
'name' => 'banner_status',
|
89 |
+
'values' => array(
|
90 |
+
|
91 |
+
array(
|
92 |
+
'value' => 1,
|
93 |
+
'label' => Mage::helper('srdt_slider')->__('Enabled'),
|
94 |
+
),
|
95 |
+
|
96 |
+
array(
|
97 |
+
'value' => 0,
|
98 |
+
'label' => Mage::helper('srdt_slider')->__('Disabled'),
|
99 |
+
),
|
100 |
+
),
|
101 |
+
));
|
102 |
+
|
103 |
+
|
104 |
+
$form->setValues($data);
|
105 |
+
|
106 |
+
return parent::_prepareForm();
|
107 |
+
}
|
108 |
+
|
109 |
+
|
110 |
+
|
111 |
+
protected function _prepareLayout() {
|
112 |
+
// echo "forms prepare layout";
|
113 |
+
// exit;
|
114 |
+
$return = parent::_prepareLayout();
|
115 |
+
if (Mage::getSingleton('cms/wysiwyg_config')->isEnabled()) {
|
116 |
+
$this->getLayout()->getBlock('head')->setCanLoadTinyMce(true);
|
117 |
+
}
|
118 |
+
return $return;
|
119 |
+
}
|
120 |
+
|
121 |
+
}
|
122 |
+
|
123 |
+
echo '<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>';
|
124 |
+
echo '<script type="text/javascript" src="http://192.200.12.89/projects/magento/js/jquery/jquery.noconflict.js"></script>';
|
125 |
+
echo "<script type=\"text/javascript\">
|
126 |
+
|
127 |
+
function checkBannerType(id)
|
128 |
+
{
|
129 |
+
if(id==1)
|
130 |
+
{
|
131 |
+
$(\"banner_caption\").closest(\"tr\").hide();
|
132 |
+
$(\"banner_image\").closest(\"tr\").hide();
|
133 |
+
$(\"banner_url\").closest(\"tr\").hide();
|
134 |
+
$(\"banner_caption\").removeClassName('required-entry');
|
135 |
+
$(\"banner_image\").removeClassName('required-entry');
|
136 |
+
$(\"banner_url\").removeClassName('required-entry');
|
137 |
+
$(\"youtube_url\").closest(\"tr\").show();
|
138 |
+
$(\"youtube_url\").addClassName('required-entry');
|
139 |
+
}
|
140 |
+
else
|
141 |
+
{
|
142 |
+
$(\"banner_caption\").closest(\"tr\").show();
|
143 |
+
$(\"banner_image\").closest(\"tr\").show();
|
144 |
+
$(\"banner_url\").closest(\"tr\").show();
|
145 |
+
$(\"banner_caption\").addClassName('required-entry');
|
146 |
+
|
147 |
+
$(\"banner_url\").addClassName('required-entry');
|
148 |
+
$(\"youtube_url\").closest(\"tr\").hide();
|
149 |
+
$(\"youtube_url\").removeClassName('required-entry');
|
150 |
+
}
|
151 |
+
}
|
152 |
+
jQuery(window).load(function() {
|
153 |
+
var id=jQuery(\"#banner_type\").val();
|
154 |
+
checkBannerType(id)
|
155 |
+
});
|
156 |
+
</script>";
|
157 |
+
|
app/code/local/Srdt/Slider/Block/Adminhtml/Slider/Edit/Tabs.php
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Srdt_Slider_Block_Adminhtml_Slider_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
|
4 |
+
{
|
5 |
+
|
6 |
+
public function __construct()
|
7 |
+
{
|
8 |
+
|
9 |
+
|
10 |
+
parent::__construct();
|
11 |
+
$this->setId('enquiry_tabs');
|
12 |
+
$this->setDestElementId('edit_form');
|
13 |
+
$this->setTitle(Mage::helper('srdt_slider')->__('Banner Slider Manager'));
|
14 |
+
}
|
15 |
+
|
16 |
+
protected function _beforeToHtml()
|
17 |
+
{
|
18 |
+
|
19 |
+
$this->addTab('form_section', array(
|
20 |
+
'label' => Mage::helper('srdt_slider')->__('Banner Information'),
|
21 |
+
'title' => Mage::helper('srdt_slider')->__('Banner Information'),
|
22 |
+
'content' => $this->getLayout()->createBlock('srdt_slider/adminhtml_slider_edit_tab_form')->toHtml(),
|
23 |
+
));
|
24 |
+
|
25 |
+
return parent::_beforeToHtml();
|
26 |
+
|
27 |
+
}
|
28 |
+
}
|
app/code/local/Srdt/Slider/Block/Adminhtml/Slider/Grid.php
ADDED
@@ -0,0 +1,122 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Srdt_Slider_Block_Adminhtml_Slider_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
4 |
+
{
|
5 |
+
public function __construct()
|
6 |
+
{
|
7 |
+
|
8 |
+
parent::__construct();
|
9 |
+
$this->setId('Srdt_Slider_grid');
|
10 |
+
$this->setDefaultSort('custommodule_id');
|
11 |
+
$this->setDefaultDir('DESC');
|
12 |
+
$this->setSaveParametersInSession(true);
|
13 |
+
$this->setUseAjax(true);
|
14 |
+
}
|
15 |
+
|
16 |
+
protected function _prepareCollection()
|
17 |
+
{
|
18 |
+
|
19 |
+
$collection = Mage::getModel('slider/slider')->getCollection();
|
20 |
+
|
21 |
+
$this->setCollection($collection);
|
22 |
+
parent::_prepareCollection();
|
23 |
+
return $this;
|
24 |
+
}
|
25 |
+
|
26 |
+
|
27 |
+
protected function _prepareColumns()
|
28 |
+
{
|
29 |
+
|
30 |
+
$this->addColumn('banner_id', array(
|
31 |
+
'header' => Mage::helper('srdt_slider')->__('ID'),
|
32 |
+
'align' =>'right',
|
33 |
+
'width' => '50px',
|
34 |
+
'index' => 'banner_id',
|
35 |
+
));
|
36 |
+
|
37 |
+
$this->addColumn('banner_title', array(
|
38 |
+
'header' => Mage::helper('srdt_slider')->__('Banner Title'),
|
39 |
+
'align' =>'right',
|
40 |
+
'width' => '150px',
|
41 |
+
'index' => 'banner_title',
|
42 |
+
));
|
43 |
+
|
44 |
+
$this->addColumn('banner_caption', array(
|
45 |
+
'header' => Mage::helper('srdt_slider')->__('Caption'),
|
46 |
+
'align' =>'right',
|
47 |
+
'width' => '150px',
|
48 |
+
'index' => 'banner_caption',
|
49 |
+
|
50 |
+
));
|
51 |
+
$this->addColumn('banner_image', array(
|
52 |
+
'header' => Mage::helper('srdt_slider')->__('Image'),
|
53 |
+
'align' =>'right',
|
54 |
+
'width' => '150px',
|
55 |
+
'index' => 'banner_image',
|
56 |
+
|
57 |
+
));
|
58 |
+
$this->addColumn('banner_status', array(
|
59 |
+
'header' => Mage::helper('srdt_slider')->__('Status'),
|
60 |
+
'align' =>'right',
|
61 |
+
'width' => '25px',
|
62 |
+
'index' => 'banner_status',
|
63 |
+
|
64 |
+
));
|
65 |
+
$this->addColumn('banner_url', array(
|
66 |
+
'header' => Mage::helper('srdt_slider')->__('Banner OnCLick URL'),
|
67 |
+
'align' =>'left',
|
68 |
+
'index' => 'banner_url',
|
69 |
+
|
70 |
+
));
|
71 |
+
|
72 |
+
|
73 |
+
$this->addColumn('action',
|
74 |
+
array(
|
75 |
+
'header' => Mage::helper('srdt_slider')->__('Action'),
|
76 |
+
'width' => '100',
|
77 |
+
'type' => 'action',
|
78 |
+
'getter' => 'getBannerId',
|
79 |
+
'actions' => array(
|
80 |
+
array(
|
81 |
+
'caption' => Mage::helper('srdt_slider')->__('Edit'),
|
82 |
+
'url' => array('base'=> '*/*/edit'),
|
83 |
+
'field' => 'id'
|
84 |
+
)
|
85 |
+
),
|
86 |
+
'filter' => false,
|
87 |
+
'sortable' => false,
|
88 |
+
'index' => 'stores',
|
89 |
+
'is_system' => true,
|
90 |
+
));
|
91 |
+
|
92 |
+
|
93 |
+
$this->addExportType('*/*/exportCsv', Mage::helper('srdt_slider')->__('CSV'));
|
94 |
+
$this->addExportType('*/*/exportXml', Mage::helper('srdt_slider')->__('XML'));
|
95 |
+
|
96 |
+
return parent::_prepareColumns();
|
97 |
+
}
|
98 |
+
|
99 |
+
protected function _prepareMassaction()
|
100 |
+
{
|
101 |
+
$this->setMassactionIdField('banner_id');
|
102 |
+
$this->getMassactionBlock()->setFormFieldName('Banner Slider');
|
103 |
+
|
104 |
+
$this->getMassactionBlock()->addItem('delete', array(
|
105 |
+
'label' => Mage::helper('srdt_slider')->__('Delete'),
|
106 |
+
'url' => $this->getUrl('*/*/massDelete'),
|
107 |
+
'confirm' => Mage::helper('srdt_slider')->__('Are you sure?')
|
108 |
+
));
|
109 |
+
|
110 |
+
|
111 |
+
|
112 |
+
return $this;
|
113 |
+
}
|
114 |
+
|
115 |
+
public function getRowUrl($row)
|
116 |
+
{
|
117 |
+
|
118 |
+
return $this->getUrl('*/*/edit', array('id' => $row->getBannerId()));
|
119 |
+
}
|
120 |
+
|
121 |
+
|
122 |
+
}
|
app/code/local/Srdt/Slider/Block/Banner.php
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Srdt_Slider_Block_Banner extends Mage_Core_Block_Template
|
3 |
+
{
|
4 |
+
public function getBanners()
|
5 |
+
{
|
6 |
+
// echo "inside function";
|
7 |
+
// exit;
|
8 |
+
$collection=Mage::getModel('slider/slider')->getCollection()->addFieldToFilter('banner_status',1);
|
9 |
+
// echo "inside function";
|
10 |
+
// exit;
|
11 |
+
return $collection;
|
12 |
+
}
|
13 |
+
public function getVideoId($youtube_url)
|
14 |
+
{
|
15 |
+
|
16 |
+
$url = $youtube_url;
|
17 |
+
// Extracts the YouTube ID from various URL structures
|
18 |
+
|
19 |
+
if (preg_match('%(?:youtube(?:-nocookie)?\.com/(?:[^/]+/.+/|(?:v|e(?:mbed)?)/|.*[?&]v=)|youtu\.be/)([^"&?/ ]{11})%i', $url, $match)) {
|
20 |
+
$id = $match[1];
|
21 |
+
return $id;
|
22 |
+
}
|
23 |
+
else
|
24 |
+
return false;
|
25 |
+
|
26 |
+
}
|
27 |
+
|
28 |
+
|
29 |
+
|
30 |
+
|
31 |
+
}
|
32 |
+
|
33 |
+
|
34 |
+
|
35 |
+
|
app/code/local/Srdt/Slider/Helper/Data.php
ADDED
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Srdt_Slider_Helper_Data extends Mage_Core_Helper_Data
|
3 |
+
{
|
4 |
+
public function deleteImageFile($image) {
|
5 |
+
if (!$image) {
|
6 |
+
return;
|
7 |
+
}
|
8 |
+
$name = $this->reImageName($image);
|
9 |
+
$banner_image_path = Mage::getBaseUrl('media') . DS . 'bannerslider' . DS . $name;
|
10 |
+
if (!file_exists($banner_image_path)) {
|
11 |
+
return;
|
12 |
+
}
|
13 |
+
|
14 |
+
try {
|
15 |
+
unlink($banner_image_path);
|
16 |
+
} catch (Exception $exc) {
|
17 |
+
echo $exc->getTraceAsString();
|
18 |
+
}
|
19 |
+
}
|
20 |
+
|
21 |
+
public static function uploadBannerImage() {
|
22 |
+
$banner_image_path = Mage::getBaseDir('media') . DS . 'bannerslider';
|
23 |
+
$image = "";
|
24 |
+
if (isset($_FILES['image']['name']) && $_FILES['image']['name'] != '') {
|
25 |
+
try {
|
26 |
+
/* Starting upload */
|
27 |
+
$uploader = new Varien_File_Uploader('image');
|
28 |
+
|
29 |
+
// Any extention would work
|
30 |
+
$uploader->setAllowedSrdts(array('jpg', 'jpeg', 'gif', 'png'));
|
31 |
+
$uploader->setAllowRenameFiles(false);
|
32 |
+
|
33 |
+
$uploader->setFilesDispersion(true);
|
34 |
+
|
35 |
+
$uploader->save($banner_image_path, $_FILES['image']['name']);
|
36 |
+
} catch (Exception $e) {
|
37 |
+
|
38 |
+
}
|
39 |
+
|
40 |
+
$image = $_FILES['image']['name'];
|
41 |
+
}
|
42 |
+
return $image;
|
43 |
+
}
|
44 |
+
|
45 |
+
public function reImageName($imageName) {
|
46 |
+
|
47 |
+
$subname = substr($imageName, 0, 2);
|
48 |
+
$array = array();
|
49 |
+
$subDir1 = substr($subname, 0, 1);
|
50 |
+
$subDir2 = substr($subname, 1, 1);
|
51 |
+
$array[0] = $subDir1;
|
52 |
+
$array[1] = $subDir2;
|
53 |
+
$name = $array[0] . '/' . $array[1] . '/' . $imageName;
|
54 |
+
|
55 |
+
return strtolower($name);
|
56 |
+
}
|
57 |
+
|
58 |
+
public function getBannerImage($image) {
|
59 |
+
$name = $this->reImageName($image);
|
60 |
+
return Mage::getBaseUrl('media') . 'bannerslider' . '/' . $name;
|
61 |
+
}
|
62 |
+
|
63 |
+
public function getPathImageForBanner($image) {
|
64 |
+
$name = $this->reImageName($image);
|
65 |
+
return 'bannerslider' . '/' . $name;
|
66 |
+
}
|
67 |
+
}
|
app/code/local/Srdt/Slider/Model/Resource/Slider.php
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Srdt_Slider_Model_Resource_Slider extends Mage_Core_Model_Resource_Db_Abstract
|
3 |
+
{
|
4 |
+
/**
|
5 |
+
* Initialize resource model
|
6 |
+
*
|
7 |
+
* @return void
|
8 |
+
*/
|
9 |
+
public function _construct()
|
10 |
+
{
|
11 |
+
$this->_init('slider/slider', 'banner_id');
|
12 |
+
}
|
13 |
+
}
|
app/code/local/Srdt/Slider/Model/Resource/Slider/Collection.php
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Srdt_Slider_Model_Resource_Slider_Collection
|
3 |
+
extends Mage_Core_Model_Resource_Db_Collection_Abstract{
|
4 |
+
protected function _constuct(){
|
5 |
+
$this->_init('slider/slider');
|
6 |
+
}
|
7 |
+
}
|
app/code/local/Srdt/Slider/Model/Slider.php
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Srdt_Slider_Model_Slider extends Mage_Core_Model_Abstract
|
3 |
+
{
|
4 |
+
public function _construct()
|
5 |
+
{
|
6 |
+
$this->_init('slider/slider');
|
7 |
+
}
|
8 |
+
}
|
app/code/local/Srdt/Slider/controllers/Adminhtml/IndexController.php
ADDED
@@ -0,0 +1,189 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Srdt_Slider_Adminhtml_IndexController extends Mage_Adminhtml_Controller_Action
|
4 |
+
{
|
5 |
+
public function indexAction()
|
6 |
+
{
|
7 |
+
$this->loadLayout();
|
8 |
+
$this->loadLayout();
|
9 |
+
$this->_setActiveMenu('srdt');
|
10 |
+
$this->_addContent($this->getLayout()->createBlock('srdt_slider/adminhtml_slider'));
|
11 |
+
$this->renderLayout();
|
12 |
+
|
13 |
+
}
|
14 |
+
|
15 |
+
public function gridAction()
|
16 |
+
{
|
17 |
+
|
18 |
+
$this->loadLayout();
|
19 |
+
$this->getResponse()->setBody($this->getLayout()->createBlock('srdt_slider/adminhtml_enquiry_grid')->toHtml()
|
20 |
+
);
|
21 |
+
}
|
22 |
+
|
23 |
+
public function exportInchooCsvAction()
|
24 |
+
{
|
25 |
+
$fileName = 'srdt_slider.csv';
|
26 |
+
$grid = $this->getLayout()->createBlock('srdt_slider/adminhtml_enquiry_grid');
|
27 |
+
$this->_prepareDownloadResponse($fileName, $grid->getCsvFile());
|
28 |
+
}
|
29 |
+
|
30 |
+
public function exportInchooExcelAction()
|
31 |
+
{
|
32 |
+
$fileName = 'srdt_slider.xml';
|
33 |
+
$grid = $this->getLayout()->createBlock('srdt_slider/adminhtml_enquiry_grid');
|
34 |
+
$this->_prepareDownloadResponse($fileName, $grid->getExcelFile($fileName));
|
35 |
+
}
|
36 |
+
|
37 |
+
|
38 |
+
public function massDeleteAction() {
|
39 |
+
$enquiry_ids = $this->getRequest()->getParam('enquiry');
|
40 |
+
if (!is_array($enquiry_ids)) {
|
41 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Please select item(s)'));
|
42 |
+
} else {
|
43 |
+
try {
|
44 |
+
foreach ($enquiry_ids as $enquiry_id) {
|
45 |
+
$enquiry_del = Mage::getModel('slider/slider')->load($enquiry_id);
|
46 |
+
$enquiry_del->delete();
|
47 |
+
}
|
48 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Total of %d record(s) were successfully deleted', count($enquiry_ids)));
|
49 |
+
} catch (Exception $e) {
|
50 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
51 |
+
}
|
52 |
+
}
|
53 |
+
$this->_redirect('*/*/index', array('store' => $this->getRequest()->getParam("store")));
|
54 |
+
}
|
55 |
+
public function editAction() {
|
56 |
+
$id = $this->getRequest()->getParam('id');
|
57 |
+
$model = Mage::getModel('slider/slider')->load($id);
|
58 |
+
if ($model->getBannerId() || $id == 0) {
|
59 |
+
$data = Mage::getSingleton('adminhtml/session')->getFormData(true);
|
60 |
+
if (!empty($data))
|
61 |
+
$model->setData($data);
|
62 |
+
|
63 |
+
Mage::register('banner_data', $model);
|
64 |
+
|
65 |
+
$this->loadLayout();
|
66 |
+
$this->_setActiveMenu('srdt');
|
67 |
+
|
68 |
+
$this->_addBreadcrumb(Mage::helper('adminhtml')->__('Enquiry Manager'), Mage::helper('adminhtml')->__('Banner Manager'));
|
69 |
+
$this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item News'), Mage::helper('adminhtml')->__('Item News'));
|
70 |
+
|
71 |
+
$this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
|
72 |
+
$this->_addContent($this->getLayout()->createBlock('srdt_slider/adminhtml_slider_edit'))
|
73 |
+
->_addLeft($this->getLayout()->createBlock('srdt_slider/adminhtml_slider_edit_tabs'));
|
74 |
+
|
75 |
+
$this->renderLayout();
|
76 |
+
|
77 |
+
} else {
|
78 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('srdt_slider')->__('Enquiry does not exist'));
|
79 |
+
$this->_redirect('*/*/');
|
80 |
+
}
|
81 |
+
}
|
82 |
+
/**
|
83 |
+
* save item action
|
84 |
+
*/
|
85 |
+
/**
|
86 |
+
* save item action
|
87 |
+
*/
|
88 |
+
public function saveAction() {
|
89 |
+
if ($data = $this->getRequest ()->getPost ()) {
|
90 |
+
if ($data ['banner_type'] == 2 && isset ( $_FILES ['banner_image'] ['name'] ) and (file_exists ( $_FILES ['banner_image'] ['tmp_name'] ))) {
|
91 |
+
try {
|
92 |
+
$uploader = new Varien_File_Uploader ( 'banner_image' );
|
93 |
+
$uploader->setAllowedExtensions ( array (
|
94 |
+
'jpg',
|
95 |
+
'jpeg',
|
96 |
+
'gif',
|
97 |
+
'png'
|
98 |
+
) ); // or pdf or anything
|
99 |
+
|
100 |
+
$uploader->setAllowRenameFiles ( true );
|
101 |
+
|
102 |
+
// setAllowRenameFiles(true) -> move your file in a folder the magento way
|
103 |
+
// setAllowRenameFiles(true) -> move your file directly in the $path folder
|
104 |
+
$uploader->setFilesDispersion ( false );
|
105 |
+
|
106 |
+
$path = Mage::getBaseDir ( 'media' ) . DS."bannerslider";
|
107 |
+
|
108 |
+
$uploader->save ( $path, $_FILES ['banner_image'] ['name'] );
|
109 |
+
|
110 |
+
$data ['banner_image'] = $_FILES ['banner_image'] ['name'];
|
111 |
+
} catch ( Exception $e ) {
|
112 |
+
}
|
113 |
+
} else {
|
114 |
+
|
115 |
+
if (isset ( $data ['banner_image'] ['delete'] ) && $data ['banner_image'] ['delete'] == 1)
|
116 |
+
$data ['image_main'] = '';
|
117 |
+
else
|
118 |
+
unset ( $data ['banner_image'] );
|
119 |
+
}
|
120 |
+
if(isset ( $data ['banner_type']) && $data ['banner_type'] == 1)
|
121 |
+
{
|
122 |
+
$data ['banner_caption'] ='';
|
123 |
+
$data ['banner_image'] ='';
|
124 |
+
$data ['banner_url'] ='';
|
125 |
+
|
126 |
+
}
|
127 |
+
else
|
128 |
+
{
|
129 |
+
$data ['youtube_url'] ='';
|
130 |
+
}
|
131 |
+
|
132 |
+
|
133 |
+
$model = Mage::getModel ( 'slider/slider' );
|
134 |
+
$model->setData ( $data )->setId ( $this->getRequest ()->getParam ( 'id' ) );
|
135 |
+
// Zend_debug::dump($model->getData());die();
|
136 |
+
try {
|
137 |
+
|
138 |
+
$model->save ();
|
139 |
+
|
140 |
+
// Zend_debug::dump($selectBanner->getData());die();
|
141 |
+
|
142 |
+
Mage::getSingleton ( 'adminhtml/session' )->addSuccess ( Mage::helper ( 'srdt_slider' )->__ ( 'Banner was successfully Saved' ) );
|
143 |
+
Mage::getSingleton ( 'adminhtml/session' )->setFormData ( false );
|
144 |
+
|
145 |
+
if ($this->getRequest ()->getParam ( 'back' )) {
|
146 |
+
$this->_redirect ( '*/*/edit', array (
|
147 |
+
'id' => $model->getId ()
|
148 |
+
) );
|
149 |
+
return;
|
150 |
+
}
|
151 |
+
$this->_redirect ( '*/*/' );
|
152 |
+
return;
|
153 |
+
} catch ( Exception $e ) {
|
154 |
+
Mage::getSingleton ( 'adminhtml/session' )->addError ( $e->getMessage () );
|
155 |
+
Mage::getSingleton ( 'adminhtml/session' )->setFormData ( $data );
|
156 |
+
$this->_redirect ( '*/*/edit', array (
|
157 |
+
'id' => $this->getRequest ()->getParam ( 'id' )
|
158 |
+
) );
|
159 |
+
return;
|
160 |
+
}
|
161 |
+
}
|
162 |
+
Mage::getSingleton ( 'adminhtml/session' )->addError ( Mage::helper ( 'srdt_slider' )->__ ( 'Unable to find Banner to save' ) );
|
163 |
+
$this->_redirect ( '*/*/' );
|
164 |
+
}
|
165 |
+
|
166 |
+
|
167 |
+
/**
|
168 |
+
* delete item action
|
169 |
+
*/
|
170 |
+
public function deleteAction() {
|
171 |
+
if ($this->getRequest()->getParam('id') > 0) {
|
172 |
+
try {
|
173 |
+
$model = Mage::getModel('slider/slider');
|
174 |
+
$model->setId($this->getRequest()->getParam('id'))
|
175 |
+
->delete();
|
176 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Enquiry was successfully deleted'));
|
177 |
+
$this->_redirect('*/*/');
|
178 |
+
} catch (Exception $e) {
|
179 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
180 |
+
$this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
|
181 |
+
}
|
182 |
+
}
|
183 |
+
$this->_redirect('*/*/');
|
184 |
+
}
|
185 |
+
|
186 |
+
public function newAction() {
|
187 |
+
$this->_forward('edit');
|
188 |
+
}
|
189 |
+
}
|
app/code/local/Srdt/Slider/etc/adminhtml.xml
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<config>
|
2 |
+
<menu>
|
3 |
+
<srdt translate="title">
|
4 |
+
<title>SRDT</title>
|
5 |
+
<sort_order>100</sort_order>
|
6 |
+
<children>
|
7 |
+
<sub_menu1 translate="title" >
|
8 |
+
<title>Manage Banners</title>
|
9 |
+
<sort_order>100</sort_order>
|
10 |
+
<action>srdtslideradmin/adminhtml_index/index/</action>
|
11 |
+
</sub_menu1>
|
12 |
+
|
13 |
+
</children>
|
14 |
+
</srdt>
|
15 |
+
</menu>
|
16 |
+
</config>
|
app/code/local/Srdt/Slider/etc/config.xml
ADDED
@@ -0,0 +1,81 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Srdt_Slider>
|
5 |
+
<version>1.0.0</version>
|
6 |
+
</Srdt_Slider>
|
7 |
+
</modules>
|
8 |
+
<!-- start of block -->
|
9 |
+
<global>
|
10 |
+
<models>
|
11 |
+
<slider>
|
12 |
+
<class>Srdt_Slider_Model</class>
|
13 |
+
<resourceModel>slider_resource</resourceModel>
|
14 |
+
</slider>
|
15 |
+
<slider_resource>
|
16 |
+
<class>Srdt_Slider_Model_Resource</class>
|
17 |
+
<entities>
|
18 |
+
<slider>
|
19 |
+
<table>slider</table>
|
20 |
+
</slider>
|
21 |
+
</entities>
|
22 |
+
</slider_resource>
|
23 |
+
</models>
|
24 |
+
<resources>
|
25 |
+
<slider_setup>
|
26 |
+
<setup>
|
27 |
+
<module>Srdt_Slider</module>
|
28 |
+
</setup>
|
29 |
+
<connection>
|
30 |
+
<use>core_setup</use>
|
31 |
+
</connection>
|
32 |
+
</slider_setup>
|
33 |
+
<slider_read>
|
34 |
+
<connection>
|
35 |
+
<use>core_read</use>
|
36 |
+
</connection>
|
37 |
+
</slider_read>
|
38 |
+
<slider_write>
|
39 |
+
<connection>
|
40 |
+
<use>core_write</use>
|
41 |
+
</connection>
|
42 |
+
</slider_write>
|
43 |
+
</resources>
|
44 |
+
<!-- start of block -->
|
45 |
+
<blocks>
|
46 |
+
<srdt_slider>
|
47 |
+
<class>Srdt_Slider_Block</class>
|
48 |
+
</srdt_slider>
|
49 |
+
</blocks>
|
50 |
+
|
51 |
+
<helpers>
|
52 |
+
<srdt_slider>
|
53 |
+
<class>Srdt_Slider_Helper</class>
|
54 |
+
</srdt_slider>
|
55 |
+
</helpers>
|
56 |
+
</global>
|
57 |
+
|
58 |
+
<!-- start of routers-->
|
59 |
+
<frontend>
|
60 |
+
<routers>
|
61 |
+
<slider>
|
62 |
+
<use>standard</use>
|
63 |
+
<args>
|
64 |
+
<module>Srdt_Slider</module>
|
65 |
+
<frontName>srdtslider</frontName>
|
66 |
+
</args>
|
67 |
+
</slider>
|
68 |
+
</routers>
|
69 |
+
</frontend>
|
70 |
+
<admin>
|
71 |
+
<routers>
|
72 |
+
<srdtslideradmin>
|
73 |
+
<use>admin</use>
|
74 |
+
<args>
|
75 |
+
<module>Srdt_Slider</module>
|
76 |
+
<frontName>srdtslideradmin</frontName>
|
77 |
+
</args>
|
78 |
+
</srdtslideradmin>
|
79 |
+
</routers>
|
80 |
+
</admin>
|
81 |
+
</config>
|
app/code/local/Srdt/Slider/sql/slider_setup/install-1.0.0.php
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
$installer=$this;
|
3 |
+
$installer->startSetup();
|
4 |
+
$installer->run("
|
5 |
+
DROP TABLE IF EXISTS {$this->getTable('slider')};
|
6 |
+
CREATE TABLE {$this->getTable('slider')} (
|
7 |
+
`banner_id` int(11) unsigned NOT NULL auto_increment COMMENT 'id',
|
8 |
+
`banner_title` varchar(255) NOT NULL COMMENT 'Title',
|
9 |
+
`banner_type` int(11) unsigned NOT NULL COMMENT 'Banner Type Video Or Image',
|
10 |
+
`banner_caption` varchar(255) COMMENT 'caption',
|
11 |
+
`banner_image` varchar(255) COMMENT 'Banner Image',
|
12 |
+
`youtube_url` varchar(255) COMMENT 'Youtube Image',
|
13 |
+
`banner_status` boolean NOT NULL COMMENT 'Status',
|
14 |
+
`banner_url` varchar(255) COMMENT 'url to redirect',
|
15 |
+
PRIMARY KEY (`banner_id`)
|
16 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
17 |
+
");
|
18 |
+
$installer->endSetup();
|
19 |
+
?>
|
app/design/frontend/base/default/template/banner/slider.phtml
ADDED
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
<?php
|
3 |
+
// echo "before loop";
|
4 |
+
$banners=$this->getBanners();
|
5 |
+
// echo "abhishek";
|
6 |
+
// exit;
|
7 |
+
?>
|
8 |
+
<?php if($banners->getSize()>0) { ?>
|
9 |
+
<script type="text/javascript" src="<?php echo $this->getSkinUrl('js/srdt/jquery.bxslider.js'); ?>"></script>
|
10 |
+
<script type="text/javascript" src="<?php echo $this->getSkinUrl('js/srdt/jquery.fitvids.js'); ?>"></script>
|
11 |
+
<link rel="stylesheet" type="text/css" href="<?php echo $this->getSkinUrl('css/srdt/jquery.bxslider.css'); ?>" media="all">
|
12 |
+
<div class="conatiner" style="width:100%;float:left;border:0px dotted red">
|
13 |
+
<ul class="bxslider">
|
14 |
+
<?php foreach ($banners as $banner): ?>
|
15 |
+
<?php if($banner->getBannerType()==2): ?>
|
16 |
+
<?php
|
17 |
+
$url=$banner->getBannerUrl();
|
18 |
+
if($url){
|
19 |
+
if (!preg_match("~^(?:f|ht)tps?://~i", $url)) {
|
20 |
+
$url = "http://" . $url;
|
21 |
+
}}else{
|
22 |
+
$url="javascript:void(0)";
|
23 |
+
}
|
24 |
+
|
25 |
+
?>
|
26 |
+
<li><a href="<?php echo $url; ?>" />
|
27 |
+
<img src="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA)."bannerslider/".$banner->getBannerImage()?>" <?php if($banner->getBannerCaption()): ?>title="<?php echo $banner->getBannerCaption(); ?>" <?php endif;?> /></a>
|
28 |
+
</li>
|
29 |
+
<?php elseif($video_id=$this->getVideoId($banner->getYoutubeUrl())): ?>
|
30 |
+
|
31 |
+
<li>
|
32 |
+
<iframe style="width:100%;" src="https://www.youtube.com/embed/<?php echo $video_id ?>" frameborder="0" allowfullscreen></iframe>
|
33 |
+
</li>
|
34 |
+
|
35 |
+
|
36 |
+
<?php endif; ?>
|
37 |
+
|
38 |
+
<?php endforeach; ?>
|
39 |
+
|
40 |
+
</ul>
|
41 |
+
|
42 |
+
|
43 |
+
</div>
|
44 |
+
|
45 |
+
<script>
|
46 |
+
$kkk=jQuery.noConflict();
|
47 |
+
$kkk('.bxslider').bxSlider({
|
48 |
+
// mode: 'fade',
|
49 |
+
// captions: true
|
50 |
+
adaptiveHeight:true,
|
51 |
+
video: true,
|
52 |
+
useCSS: false,
|
53 |
+
captions: true
|
54 |
+
});
|
55 |
+
</script>
|
56 |
+
<?php }
|
57 |
+
|
58 |
+
else{
|
59 |
+
echo "Either you have not added sliders or All the sliders are disable";
|
60 |
+
}
|
61 |
+
?>
|
app/etc/modules/Srdt_Slider.xml
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<config>
|
2 |
+
<modules>
|
3 |
+
<Srdt_Slider>
|
4 |
+
<codePool>local</codePool>
|
5 |
+
<active>true</active>
|
6 |
+
</Srdt_Slider>
|
7 |
+
</modules>
|
8 |
+
</config>
|
9 |
+
|
package.xml
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>Srdt_Banner_Slider</name>
|
4 |
+
<version>1.0.0</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL)</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>This Extension Let you add Banner slider on any page(Video or Image);</summary>
|
10 |
+
<description>This Extension Lets you add banner slider either using image or youtube video.Both the banner video or image will be responsive by default.In admin you can select whether you want to use video or image.</description>
|
11 |
+
<notes>First release of the extension</notes>
|
12 |
+
<authors><author><name>Abhishek Dixit</name><user>staywithabhi</user><email>er.abhishek_integral@rediffmail.com</email></author><author><name>pushpendra tiwari</name><user>pushpendra</user><email>veerutiwari7@gmail.com</email></author><author><name>prakash kumar</name><user>prakash_kumar</user><email>prakash_kumar0068@hotmail.com</email></author><author><name>Vijay Kumar</name><user>vijay_panacea</user><email>vijay_panacea92@gmail.com</email></author></authors>
|
13 |
+
<date>2016-01-04</date>
|
14 |
+
<time>08:32:57</time>
|
15 |
+
<contents><target name="magelocal"><dir name="Srdt"><dir name="Slider"><dir name="Block"><dir name="Adminhtml"><dir name="Slider"><dir name="Edit"><file name="Form.php" hash="e88d45cbd5483ab9d01bc3d56c4ddd6c"/><dir name="Tab"><file name="Form.php" hash="0e03738d54bc9a0c30af98de3efd8aae"/></dir><file name="Tabs.php" hash="96e0883c0cf52d21d28e29d173c6eab5"/></dir><file name="Edit.php" hash="b07bc0f0c43d4c2b3f861d993354b40a"/><file name="Grid.php" hash="eb823fb6d5612c665b5243f48089ea87"/></dir><file name="Slider.php" hash="67ed4667e5d24e036bd40f6c52f4b416"/></dir><file name="Banner.php" hash="8079c78dbcc2309960f7abb00972a9b5"/></dir><dir name="Helper"><file name="Data.php" hash="9f379e483aa08f4c1ce229cfa0862ac3"/></dir><dir name="Model"><dir name="Resource"><dir name="Slider"><file name="Collection.php" hash="ad8e35be7412e44de7bcf2e164682e8e"/></dir><file name="Slider.php" hash="317c635cca76e3d101c6dd67421bea81"/></dir><file name="Slider.php" hash="06bf017e4f3c6035d21a4021ab05e2b8"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="IndexController.php" hash="2abcde6155c5757bab1c7d8638a0c518"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="2fd101c76223a3161f6346a662d642aa"/><file name="config.xml" hash="1d804ae6836cad44afb2730f5a8b2546"/></dir><dir name="sql"><dir name="slider_setup"><file name="install-1.0.0.php" hash="a3515c0fa06d7b93bac4f4679019a162"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Srdt_Slider.xml" hash="a45ce0e4d3a5f9009c4e2613c132dba9"/></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="banner"><file name="slider.phtml" hash="a182a87c4c1c5761c0e821b4c964d670"/></dir></dir></dir></dir></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="css"><dir name="srdt"><file name="jquery.bxslider.css" hash="4ee5165078fec8053e2205cbc63798fe"/></dir></dir><dir name="images"><dir name="srdt"><file name="bx_loader.gif" hash="931bdb6b50816b03206c66921760b246"/><file name="controls.png" hash="d9d25372f38c6b242b9b51d5841fe86e"/></dir></dir><dir name="js"><dir name="srdt"><file name="jquery.bxslider.js" hash="b257e0969014adf4d5836b545fd6ccfc"/><file name="jquery.bxslider.min.js" hash="697d69a48e5356f7106e38c09f7f19e0"/><file name="jquery.easing.1.3.js" hash="6516449ed5089677ed3d7e2f11fc8942"/><file name="jquery.fitvids.js" hash="55e813eb3e253f97bb8053bffe8c6b49"/></dir></dir></dir></dir></dir></target></contents>
|
16 |
+
<compatible/>
|
17 |
+
<dependencies><required><php><min>5.2.0</min><max>7.0.0</max></php></required></dependencies>
|
18 |
+
</package>
|
skin/frontend/base/default/css/srdt/jquery.bxslider.css
ADDED
@@ -0,0 +1,210 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* BxSlider v4.1.2 - Fully loaded, responsive content slider
|
3 |
+
* http://bxslider.com
|
4 |
+
*
|
5 |
+
* Written by: Steven Wanderski, 2014
|
6 |
+
* http://stevenwanderski.com
|
7 |
+
* (while drinking Belgian ales and listening to jazz)
|
8 |
+
*
|
9 |
+
* CEO and founder of bxCreative, LTD
|
10 |
+
* http://bxcreative.com
|
11 |
+
*/
|
12 |
+
|
13 |
+
|
14 |
+
/** RESET AND LAYOUT
|
15 |
+
===================================*/
|
16 |
+
|
17 |
+
.bx-wrapper {
|
18 |
+
position: relative;
|
19 |
+
margin: 0 auto 60px;
|
20 |
+
padding: 0;
|
21 |
+
*zoom: 1;
|
22 |
+
}
|
23 |
+
|
24 |
+
.bx-wrapper img {
|
25 |
+
width: 100%;
|
26 |
+
display: block;
|
27 |
+
height: 100%;
|
28 |
+
margin-top:2px;
|
29 |
+
}
|
30 |
+
|
31 |
+
/** THEME
|
32 |
+
===================================*/
|
33 |
+
|
34 |
+
.bx-wrapper .bx-viewport {
|
35 |
+
-moz-box-shadow: 0 0 5px #ccc;
|
36 |
+
-webkit-box-shadow: 0 0 5px #ccc;
|
37 |
+
box-shadow: 0 0 5px #ccc;
|
38 |
+
border: 5px solid #fff;
|
39 |
+
left: -5px;
|
40 |
+
background: #fff;
|
41 |
+
|
42 |
+
/*fix other elements on the page moving (on Chrome)*/
|
43 |
+
-webkit-transform: translatez(0);
|
44 |
+
-moz-transform: translatez(0);
|
45 |
+
-ms-transform: translatez(0);
|
46 |
+
-o-transform: translatez(0);
|
47 |
+
transform: translatez(0);
|
48 |
+
}
|
49 |
+
|
50 |
+
.bx-wrapper .bx-pager,
|
51 |
+
.bx-wrapper .bx-controls-auto {
|
52 |
+
position: absolute;
|
53 |
+
bottom: -30px;
|
54 |
+
width: 100%;
|
55 |
+
}
|
56 |
+
|
57 |
+
/* LOADER */
|
58 |
+
|
59 |
+
.bx-wrapper .bx-loading {
|
60 |
+
min-height: 50px;
|
61 |
+
background: url(../../images/srdt/bx_loader.gif) center center no-repeat #fff;
|
62 |
+
height: 100%;
|
63 |
+
width: 100%;
|
64 |
+
position: absolute;
|
65 |
+
top: 0;
|
66 |
+
left: 0;
|
67 |
+
z-index: 2000;
|
68 |
+
}
|
69 |
+
.bx-wrapper .bx-viewport ul li
|
70 |
+
{
|
71 |
+
margin-left: 0;
|
72 |
+
}
|
73 |
+
|
74 |
+
/* PAGER */
|
75 |
+
|
76 |
+
.bx-wrapper .bx-pager {
|
77 |
+
text-align: center;
|
78 |
+
font-size: .85em;
|
79 |
+
font-family: Arial;
|
80 |
+
font-weight: bold;
|
81 |
+
color: #666;
|
82 |
+
padding-top: 20px;
|
83 |
+
}
|
84 |
+
|
85 |
+
.bx-wrapper .bx-pager .bx-pager-item,
|
86 |
+
.bx-wrapper .bx-controls-auto .bx-controls-auto-item {
|
87 |
+
display: inline-block;
|
88 |
+
*zoom: 1;
|
89 |
+
*display: inline;
|
90 |
+
}
|
91 |
+
|
92 |
+
.bx-wrapper .bx-pager.bx-default-pager a {
|
93 |
+
background: #666;
|
94 |
+
text-indent: -9999px;
|
95 |
+
display: block;
|
96 |
+
width: 10px;
|
97 |
+
height: 10px;
|
98 |
+
margin: 0 5px;
|
99 |
+
outline: 0;
|
100 |
+
-moz-border-radius: 5px;
|
101 |
+
-webkit-border-radius: 5px;
|
102 |
+
border-radius: 5px;
|
103 |
+
}
|
104 |
+
|
105 |
+
.bx-wrapper .bx-pager.bx-default-pager a:hover,
|
106 |
+
.bx-wrapper .bx-pager.bx-default-pager a.active {
|
107 |
+
background: #000;
|
108 |
+
}
|
109 |
+
|
110 |
+
/* DIRECTION CONTROLS (NEXT / PREV) */
|
111 |
+
|
112 |
+
.bx-wrapper .bx-prev {
|
113 |
+
left: 10px;
|
114 |
+
background: url(../../images/srdt/controls.png) no-repeat 0 -32px;
|
115 |
+
}
|
116 |
+
|
117 |
+
.bx-wrapper .bx-next {
|
118 |
+
right: 10px;
|
119 |
+
background: url(../../images/srdt/controls.png) no-repeat -43px -32px;
|
120 |
+
}
|
121 |
+
|
122 |
+
.bx-wrapper .bx-prev:hover {
|
123 |
+
background-position: 0 0;
|
124 |
+
}
|
125 |
+
|
126 |
+
.bx-wrapper .bx-next:hover {
|
127 |
+
background-position: -43px 0;
|
128 |
+
}
|
129 |
+
|
130 |
+
.bx-wrapper .bx-controls-direction a {
|
131 |
+
position: absolute;
|
132 |
+
top: 50%;
|
133 |
+
margin-top: -16px;
|
134 |
+
outline: 0;
|
135 |
+
width: 32px;
|
136 |
+
height: 32px;
|
137 |
+
text-indent: -9999px;
|
138 |
+
z-index: 9999;
|
139 |
+
}
|
140 |
+
|
141 |
+
.bx-wrapper .bx-controls-direction a.disabled {
|
142 |
+
display: none;
|
143 |
+
}
|
144 |
+
|
145 |
+
/* AUTO CONTROLS (START / STOP) */
|
146 |
+
|
147 |
+
.bx-wrapper .bx-controls-auto {
|
148 |
+
text-align: center;
|
149 |
+
}
|
150 |
+
|
151 |
+
.bx-wrapper .bx-controls-auto .bx-start {
|
152 |
+
display: block;
|
153 |
+
text-indent: -9999px;
|
154 |
+
width: 10px;
|
155 |
+
height: 11px;
|
156 |
+
outline: 0;
|
157 |
+
background: url(../../images/srdt/controls.png) -86px -11px no-repeat;
|
158 |
+
margin: 0 3px;
|
159 |
+
}
|
160 |
+
|
161 |
+
.bx-wrapper .bx-controls-auto .bx-start:hover,
|
162 |
+
.bx-wrapper .bx-controls-auto .bx-start.active {
|
163 |
+
background-position: -86px 0;
|
164 |
+
}
|
165 |
+
|
166 |
+
.bx-wrapper .bx-controls-auto .bx-stop {
|
167 |
+
display: block;
|
168 |
+
text-indent: -9999px;
|
169 |
+
width: 9px;
|
170 |
+
height: 11px;
|
171 |
+
outline: 0;
|
172 |
+
background: url(../../images/srdt/controls.png) -86px -44px no-repeat;
|
173 |
+
margin: 0 3px;
|
174 |
+
}
|
175 |
+
|
176 |
+
.bx-wrapper .bx-controls-auto .bx-stop:hover,
|
177 |
+
.bx-wrapper .bx-controls-auto .bx-stop.active {
|
178 |
+
background-position: -86px -33px;
|
179 |
+
}
|
180 |
+
|
181 |
+
/* PAGER WITH AUTO-CONTROLS HYBRID LAYOUT */
|
182 |
+
|
183 |
+
.bx-wrapper .bx-controls.bx-has-controls-auto.bx-has-pager .bx-pager {
|
184 |
+
text-align: left;
|
185 |
+
width: 80%;
|
186 |
+
}
|
187 |
+
|
188 |
+
.bx-wrapper .bx-controls.bx-has-controls-auto.bx-has-pager .bx-controls-auto {
|
189 |
+
right: 0;
|
190 |
+
width: 35px;
|
191 |
+
}
|
192 |
+
|
193 |
+
/* IMAGE CAPTIONS */
|
194 |
+
|
195 |
+
.bx-wrapper .bx-caption {
|
196 |
+
position: absolute;
|
197 |
+
bottom: 0;
|
198 |
+
left: 0;
|
199 |
+
background: #666\9;
|
200 |
+
background: rgba(80, 80, 80, 0.75);
|
201 |
+
width: 100%;
|
202 |
+
}
|
203 |
+
|
204 |
+
.bx-wrapper .bx-caption span {
|
205 |
+
color: #fff;
|
206 |
+
font-family: Arial;
|
207 |
+
display: block;
|
208 |
+
font-size: .85em;
|
209 |
+
padding: 10px;
|
210 |
+
}
|
skin/frontend/base/default/images/srdt/bx_loader.gif
ADDED
Binary file
|
skin/frontend/base/default/images/srdt/controls.png
ADDED
Binary file
|
skin/frontend/base/default/js/srdt/jquery.bxslider.js
ADDED
@@ -0,0 +1,1343 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* BxSlider v4.1.2 - Fully loaded, responsive content slider
|
3 |
+
* http://bxslider.com
|
4 |
+
*
|
5 |
+
* Copyright 2014, Steven Wanderski - http://stevenwanderski.com - http://bxcreative.com
|
6 |
+
* Written while drinking Belgian ales and listening to jazz
|
7 |
+
*
|
8 |
+
* Released under the MIT license - http://opensource.org/licenses/MIT
|
9 |
+
*/
|
10 |
+
|
11 |
+
;(function($){
|
12 |
+
|
13 |
+
var plugin = {};
|
14 |
+
|
15 |
+
var defaults = {
|
16 |
+
|
17 |
+
// GENERAL
|
18 |
+
mode: 'horizontal',
|
19 |
+
slideSelector: '',
|
20 |
+
infiniteLoop: true,
|
21 |
+
hideControlOnEnd: false,
|
22 |
+
speed: 500,
|
23 |
+
easing: null,
|
24 |
+
slideMargin: 0,
|
25 |
+
startSlide: 0,
|
26 |
+
randomStart: false,
|
27 |
+
captions: false,
|
28 |
+
ticker: false,
|
29 |
+
tickerHover: false,
|
30 |
+
adaptiveHeight: false,
|
31 |
+
adaptiveHeightSpeed: 500,
|
32 |
+
video: false,
|
33 |
+
useCSS: true,
|
34 |
+
preloadImages: 'visible',
|
35 |
+
responsive: true,
|
36 |
+
slideZIndex: 50,
|
37 |
+
wrapperClass: 'bx-wrapper',
|
38 |
+
|
39 |
+
// TOUCH
|
40 |
+
touchEnabled: true,
|
41 |
+
swipeThreshold: 50,
|
42 |
+
oneToOneTouch: true,
|
43 |
+
preventDefaultSwipeX: true,
|
44 |
+
preventDefaultSwipeY: false,
|
45 |
+
|
46 |
+
// PAGER
|
47 |
+
pager: true,
|
48 |
+
pagerType: 'full',
|
49 |
+
pagerShortSeparator: ' / ',
|
50 |
+
pagerSelector: null,
|
51 |
+
buildPager: null,
|
52 |
+
pagerCustom: null,
|
53 |
+
|
54 |
+
// CONTROLS
|
55 |
+
controls: true,
|
56 |
+
nextText: 'Next',
|
57 |
+
prevText: 'Prev',
|
58 |
+
nextSelector: null,
|
59 |
+
prevSelector: null,
|
60 |
+
autoControls: false,
|
61 |
+
startText: 'Start',
|
62 |
+
stopText: 'Stop',
|
63 |
+
autoControlsCombine: false,
|
64 |
+
autoControlsSelector: null,
|
65 |
+
|
66 |
+
// AUTO
|
67 |
+
auto: false,
|
68 |
+
pause: 4000,
|
69 |
+
autoStart: true,
|
70 |
+
autoDirection: 'next',
|
71 |
+
autoHover: false,
|
72 |
+
autoDelay: 0,
|
73 |
+
autoSlideForOnePage: false,
|
74 |
+
|
75 |
+
// CAROUSEL
|
76 |
+
minSlides: 1,
|
77 |
+
maxSlides: 1,
|
78 |
+
moveSlides: 0,
|
79 |
+
slideWidth: 0,
|
80 |
+
|
81 |
+
// CALLBACKS
|
82 |
+
onSliderLoad: function() {},
|
83 |
+
onSlideBefore: function() {},
|
84 |
+
onSlideAfter: function() {},
|
85 |
+
onSlideNext: function() {},
|
86 |
+
onSlidePrev: function() {},
|
87 |
+
onSliderResize: function() {}
|
88 |
+
}
|
89 |
+
|
90 |
+
$.fn.bxSlider = function(options){
|
91 |
+
|
92 |
+
if(this.length == 0) return this;
|
93 |
+
|
94 |
+
// support mutltiple elements
|
95 |
+
if(this.length > 1){
|
96 |
+
this.each(function(){$(this).bxSlider(options)});
|
97 |
+
return this;
|
98 |
+
}
|
99 |
+
|
100 |
+
// create a namespace to be used throughout the plugin
|
101 |
+
var slider = {};
|
102 |
+
// set a reference to our slider element
|
103 |
+
var el = this;
|
104 |
+
plugin.el = this;
|
105 |
+
|
106 |
+
/**
|
107 |
+
* Makes slideshow responsive
|
108 |
+
*/
|
109 |
+
// first get the original window dimens (thanks alot IE)
|
110 |
+
var windowWidth = $(window).width();
|
111 |
+
var windowHeight = $(window).height();
|
112 |
+
|
113 |
+
|
114 |
+
|
115 |
+
/**
|
116 |
+
* ===================================================================================
|
117 |
+
* = PRIVATE FUNCTIONS
|
118 |
+
* ===================================================================================
|
119 |
+
*/
|
120 |
+
|
121 |
+
/**
|
122 |
+
* Initializes namespace settings to be used throughout plugin
|
123 |
+
*/
|
124 |
+
var init = function(){
|
125 |
+
// merge user-supplied options with the defaults
|
126 |
+
slider.settings = $.extend({}, defaults, options);
|
127 |
+
// parse slideWidth setting
|
128 |
+
slider.settings.slideWidth = parseInt(slider.settings.slideWidth);
|
129 |
+
// store the original children
|
130 |
+
slider.children = el.children(slider.settings.slideSelector);
|
131 |
+
// check if actual number of slides is less than minSlides / maxSlides
|
132 |
+
if(slider.children.length < slider.settings.minSlides) slider.settings.minSlides = slider.children.length;
|
133 |
+
if(slider.children.length < slider.settings.maxSlides) slider.settings.maxSlides = slider.children.length;
|
134 |
+
// if random start, set the startSlide setting to random number
|
135 |
+
if(slider.settings.randomStart) slider.settings.startSlide = Math.floor(Math.random() * slider.children.length);
|
136 |
+
// store active slide information
|
137 |
+
slider.active = { index: slider.settings.startSlide }
|
138 |
+
// store if the slider is in carousel mode (displaying / moving multiple slides)
|
139 |
+
slider.carousel = slider.settings.minSlides > 1 || slider.settings.maxSlides > 1;
|
140 |
+
// if carousel, force preloadImages = 'all'
|
141 |
+
if(slider.carousel) slider.settings.preloadImages = 'all';
|
142 |
+
// calculate the min / max width thresholds based on min / max number of slides
|
143 |
+
// used to setup and update carousel slides dimensions
|
144 |
+
slider.minThreshold = (slider.settings.minSlides * slider.settings.slideWidth) + ((slider.settings.minSlides - 1) * slider.settings.slideMargin);
|
145 |
+
slider.maxThreshold = (slider.settings.maxSlides * slider.settings.slideWidth) + ((slider.settings.maxSlides - 1) * slider.settings.slideMargin);
|
146 |
+
// store the current state of the slider (if currently animating, working is true)
|
147 |
+
slider.working = false;
|
148 |
+
// initialize the controls object
|
149 |
+
slider.controls = {};
|
150 |
+
// initialize an auto interval
|
151 |
+
slider.interval = null;
|
152 |
+
// determine which property to use for transitions
|
153 |
+
slider.animProp = slider.settings.mode == 'vertical' ? 'top' : 'left';
|
154 |
+
// determine if hardware acceleration can be used
|
155 |
+
slider.usingCSS = slider.settings.useCSS && slider.settings.mode != 'fade' && (function(){
|
156 |
+
// create our test div element
|
157 |
+
var div = document.createElement('div');
|
158 |
+
// css transition properties
|
159 |
+
var props = ['WebkitPerspective', 'MozPerspective', 'OPerspective', 'msPerspective'];
|
160 |
+
// test for each property
|
161 |
+
for(var i in props){
|
162 |
+
if(div.style[props[i]] !== undefined){
|
163 |
+
slider.cssPrefix = props[i].replace('Perspective', '').toLowerCase();
|
164 |
+
slider.animProp = '-' + slider.cssPrefix + '-transform';
|
165 |
+
return true;
|
166 |
+
}
|
167 |
+
}
|
168 |
+
return false;
|
169 |
+
}());
|
170 |
+
// if vertical mode always make maxSlides and minSlides equal
|
171 |
+
if(slider.settings.mode == 'vertical') slider.settings.maxSlides = slider.settings.minSlides;
|
172 |
+
// save original style data
|
173 |
+
el.data("origStyle", el.attr("style"));
|
174 |
+
el.children(slider.settings.slideSelector).each(function() {
|
175 |
+
$(this).data("origStyle", $(this).attr("style"));
|
176 |
+
});
|
177 |
+
// perform all DOM / CSS modifications
|
178 |
+
setup();
|
179 |
+
}
|
180 |
+
|
181 |
+
/**
|
182 |
+
* Performs all DOM and CSS modifications
|
183 |
+
*/
|
184 |
+
var setup = function(){
|
185 |
+
// wrap el in a wrapper
|
186 |
+
el.wrap('<div class="' + slider.settings.wrapperClass + '"><div class="bx-viewport"></div></div>');
|
187 |
+
// store a namspace reference to .bx-viewport
|
188 |
+
slider.viewport = el.parent();
|
189 |
+
// add a loading div to display while images are loading
|
190 |
+
slider.loader = $('<div class="bx-loading" />');
|
191 |
+
slider.viewport.prepend(slider.loader);
|
192 |
+
// set el to a massive width, to hold any needed slides
|
193 |
+
// also strip any margin and padding from el
|
194 |
+
el.css({
|
195 |
+
width: slider.settings.mode == 'horizontal' ? (slider.children.length * 100 + 215) + '%' : 'auto',
|
196 |
+
position: 'relative'
|
197 |
+
});
|
198 |
+
// if using CSS, add the easing property
|
199 |
+
if(slider.usingCSS && slider.settings.easing){
|
200 |
+
el.css('-' + slider.cssPrefix + '-transition-timing-function', slider.settings.easing);
|
201 |
+
// if not using CSS and no easing value was supplied, use the default JS animation easing (swing)
|
202 |
+
}else if(!slider.settings.easing){
|
203 |
+
slider.settings.easing = 'swing';
|
204 |
+
}
|
205 |
+
var slidesShowing = getNumberSlidesShowing();
|
206 |
+
// make modifications to the viewport (.bx-viewport)
|
207 |
+
slider.viewport.css({
|
208 |
+
width: '100%',
|
209 |
+
overflow: 'hidden',
|
210 |
+
position: 'relative'
|
211 |
+
});
|
212 |
+
slider.viewport.parent().css({
|
213 |
+
maxWidth: getViewportMaxWidth()
|
214 |
+
});
|
215 |
+
// make modification to the wrapper (.bx-wrapper)
|
216 |
+
if(!slider.settings.pager) {
|
217 |
+
slider.viewport.parent().css({
|
218 |
+
margin: '0 auto 0px'
|
219 |
+
});
|
220 |
+
}
|
221 |
+
// apply css to all slider children
|
222 |
+
slider.children.css({
|
223 |
+
'float': slider.settings.mode == 'horizontal' ? 'left' : 'none',
|
224 |
+
listStyle: 'none',
|
225 |
+
position: 'relative'
|
226 |
+
});
|
227 |
+
// apply the calculated width after the float is applied to prevent scrollbar interference
|
228 |
+
slider.children.css('width', getSlideWidth());
|
229 |
+
// if slideMargin is supplied, add the css
|
230 |
+
if(slider.settings.mode == 'horizontal' && slider.settings.slideMargin > 0) slider.children.css('marginRight', slider.settings.slideMargin);
|
231 |
+
if(slider.settings.mode == 'vertical' && slider.settings.slideMargin > 0) slider.children.css('marginBottom', slider.settings.slideMargin);
|
232 |
+
// if "fade" mode, add positioning and z-index CSS
|
233 |
+
if(slider.settings.mode == 'fade'){
|
234 |
+
slider.children.css({
|
235 |
+
position: 'absolute',
|
236 |
+
zIndex: 0,
|
237 |
+
display: 'none'
|
238 |
+
});
|
239 |
+
// prepare the z-index on the showing element
|
240 |
+
slider.children.eq(slider.settings.startSlide).css({zIndex: slider.settings.slideZIndex, display: 'block'});
|
241 |
+
}
|
242 |
+
// create an element to contain all slider controls (pager, start / stop, etc)
|
243 |
+
slider.controls.el = $('<div class="bx-controls" />');
|
244 |
+
// if captions are requested, add them
|
245 |
+
if(slider.settings.captions) appendCaptions();
|
246 |
+
// check if startSlide is last slide
|
247 |
+
slider.active.last = slider.settings.startSlide == getPagerQty() - 1;
|
248 |
+
// if video is true, set up the fitVids plugin
|
249 |
+
if(slider.settings.video) el.fitVids();
|
250 |
+
// set the default preload selector (visible)
|
251 |
+
var preloadSelector = slider.children.eq(slider.settings.startSlide);
|
252 |
+
if (slider.settings.preloadImages == "all") preloadSelector = slider.children;
|
253 |
+
// only check for control addition if not in "ticker" mode
|
254 |
+
if(!slider.settings.ticker){
|
255 |
+
// if pager is requested, add it
|
256 |
+
if(slider.settings.pager) appendPager();
|
257 |
+
// if controls are requested, add them
|
258 |
+
if(slider.settings.controls) appendControls();
|
259 |
+
// if auto is true, and auto controls are requested, add them
|
260 |
+
if(slider.settings.auto && slider.settings.autoControls) appendControlsAuto();
|
261 |
+
// if any control option is requested, add the controls wrapper
|
262 |
+
if(slider.settings.controls || slider.settings.autoControls || slider.settings.pager) slider.viewport.after(slider.controls.el);
|
263 |
+
// if ticker mode, do not allow a pager
|
264 |
+
}else{
|
265 |
+
slider.settings.pager = false;
|
266 |
+
}
|
267 |
+
// preload all images, then perform final DOM / CSS modifications that depend on images being loaded
|
268 |
+
loadElements(preloadSelector, start);
|
269 |
+
}
|
270 |
+
|
271 |
+
var loadElements = function(selector, callback){
|
272 |
+
var total = selector.find('img, iframe').length;
|
273 |
+
if (total == 0){
|
274 |
+
callback();
|
275 |
+
return;
|
276 |
+
}
|
277 |
+
var count = 0;
|
278 |
+
selector.find('img, iframe').each(function(){
|
279 |
+
$(this).one('load', function() {
|
280 |
+
if(++count == total) callback();
|
281 |
+
}).each(function() {
|
282 |
+
if(this.complete) $(this).load();
|
283 |
+
});
|
284 |
+
});
|
285 |
+
}
|
286 |
+
|
287 |
+
/**
|
288 |
+
* Start the slider
|
289 |
+
*/
|
290 |
+
var start = function(){
|
291 |
+
// if infinite loop, prepare additional slides
|
292 |
+
if(slider.settings.infiniteLoop && slider.settings.mode != 'fade' && !slider.settings.ticker){
|
293 |
+
var slice = slider.settings.mode == 'vertical' ? slider.settings.minSlides : slider.settings.maxSlides;
|
294 |
+
var sliceAppend = slider.children.slice(0, slice).clone().addClass('bx-clone');
|
295 |
+
var slicePrepend = slider.children.slice(-slice).clone().addClass('bx-clone');
|
296 |
+
el.append(sliceAppend).prepend(slicePrepend);
|
297 |
+
}
|
298 |
+
// remove the loading DOM element
|
299 |
+
slider.loader.remove();
|
300 |
+
// set the left / top position of "el"
|
301 |
+
setSlidePosition();
|
302 |
+
// if "vertical" mode, always use adaptiveHeight to prevent odd behavior
|
303 |
+
if (slider.settings.mode == 'vertical') slider.settings.adaptiveHeight = true;
|
304 |
+
// set the viewport height
|
305 |
+
slider.viewport.height(getViewportHeight());
|
306 |
+
// make sure everything is positioned just right (same as a window resize)
|
307 |
+
el.redrawSlider();
|
308 |
+
// onSliderLoad callback
|
309 |
+
slider.settings.onSliderLoad(slider.active.index);
|
310 |
+
// slider has been fully initialized
|
311 |
+
slider.initialized = true;
|
312 |
+
// bind the resize call to the window
|
313 |
+
if (slider.settings.responsive) $(window).bind('resize', resizeWindow);
|
314 |
+
// if auto is true and has more than 1 page, start the show
|
315 |
+
if (slider.settings.auto && slider.settings.autoStart && (getPagerQty() > 1 || slider.settings.autoSlideForOnePage)) initAuto();
|
316 |
+
// if ticker is true, start the ticker
|
317 |
+
if (slider.settings.ticker) initTicker();
|
318 |
+
// if pager is requested, make the appropriate pager link active
|
319 |
+
if (slider.settings.pager) updatePagerActive(slider.settings.startSlide);
|
320 |
+
// check for any updates to the controls (like hideControlOnEnd updates)
|
321 |
+
if (slider.settings.controls) updateDirectionControls();
|
322 |
+
// if touchEnabled is true, setup the touch events
|
323 |
+
if (slider.settings.touchEnabled && !slider.settings.ticker) initTouch();
|
324 |
+
}
|
325 |
+
|
326 |
+
/**
|
327 |
+
* Returns the calculated height of the viewport, used to determine either adaptiveHeight or the maxHeight value
|
328 |
+
*/
|
329 |
+
var getViewportHeight = function(){
|
330 |
+
var height = 0;
|
331 |
+
// first determine which children (slides) should be used in our height calculation
|
332 |
+
var children = $();
|
333 |
+
// if mode is not "vertical" and adaptiveHeight is false, include all children
|
334 |
+
if(slider.settings.mode != 'vertical' && !slider.settings.adaptiveHeight){
|
335 |
+
children = slider.children;
|
336 |
+
}else{
|
337 |
+
// if not carousel, return the single active child
|
338 |
+
if(!slider.carousel){
|
339 |
+
children = slider.children.eq(slider.active.index);
|
340 |
+
// if carousel, return a slice of children
|
341 |
+
}else{
|
342 |
+
// get the individual slide index
|
343 |
+
var currentIndex = slider.settings.moveSlides == 1 ? slider.active.index : slider.active.index * getMoveBy();
|
344 |
+
// add the current slide to the children
|
345 |
+
children = slider.children.eq(currentIndex);
|
346 |
+
// cycle through the remaining "showing" slides
|
347 |
+
for (i = 1; i <= slider.settings.maxSlides - 1; i++){
|
348 |
+
// if looped back to the start
|
349 |
+
if(currentIndex + i >= slider.children.length){
|
350 |
+
children = children.add(slider.children.eq(i - 1));
|
351 |
+
}else{
|
352 |
+
children = children.add(slider.children.eq(currentIndex + i));
|
353 |
+
}
|
354 |
+
}
|
355 |
+
}
|
356 |
+
}
|
357 |
+
// if "vertical" mode, calculate the sum of the heights of the children
|
358 |
+
if(slider.settings.mode == 'vertical'){
|
359 |
+
children.each(function(index) {
|
360 |
+
height += $(this).outerHeight();
|
361 |
+
});
|
362 |
+
// add user-supplied margins
|
363 |
+
if(slider.settings.slideMargin > 0){
|
364 |
+
height += slider.settings.slideMargin * (slider.settings.minSlides - 1);
|
365 |
+
}
|
366 |
+
// if not "vertical" mode, calculate the max height of the children
|
367 |
+
}else{
|
368 |
+
height = Math.max.apply(Math, children.map(function(){
|
369 |
+
return $(this).outerHeight(false);
|
370 |
+
}).get());
|
371 |
+
}
|
372 |
+
|
373 |
+
if(slider.viewport.css('box-sizing') == 'border-box'){
|
374 |
+
height += parseFloat(slider.viewport.css('padding-top')) + parseFloat(slider.viewport.css('padding-bottom')) +
|
375 |
+
parseFloat(slider.viewport.css('border-top-width')) + parseFloat(slider.viewport.css('border-bottom-width'));
|
376 |
+
}else if(slider.viewport.css('box-sizing') == 'padding-box'){
|
377 |
+
height += parseFloat(slider.viewport.css('padding-top')) + parseFloat(slider.viewport.css('padding-bottom'));
|
378 |
+
}
|
379 |
+
|
380 |
+
return height;
|
381 |
+
}
|
382 |
+
|
383 |
+
/**
|
384 |
+
* Returns the calculated width to be used for the outer wrapper / viewport
|
385 |
+
*/
|
386 |
+
var getViewportMaxWidth = function(){
|
387 |
+
var width = '100%';
|
388 |
+
if(slider.settings.slideWidth > 0){
|
389 |
+
if(slider.settings.mode == 'horizontal'){
|
390 |
+
width = (slider.settings.maxSlides * slider.settings.slideWidth) + ((slider.settings.maxSlides - 1) * slider.settings.slideMargin);
|
391 |
+
}else{
|
392 |
+
width = slider.settings.slideWidth;
|
393 |
+
}
|
394 |
+
}
|
395 |
+
return width;
|
396 |
+
}
|
397 |
+
|
398 |
+
/**
|
399 |
+
* Returns the calculated width to be applied to each slide
|
400 |
+
*/
|
401 |
+
var getSlideWidth = function(){
|
402 |
+
// start with any user-supplied slide width
|
403 |
+
var newElWidth = slider.settings.slideWidth;
|
404 |
+
// get the current viewport width
|
405 |
+
var wrapWidth = slider.viewport.width();
|
406 |
+
// if slide width was not supplied, or is larger than the viewport use the viewport width
|
407 |
+
if(slider.settings.slideWidth == 0 ||
|
408 |
+
(slider.settings.slideWidth > wrapWidth && !slider.carousel) ||
|
409 |
+
slider.settings.mode == 'vertical'){
|
410 |
+
newElWidth = wrapWidth;
|
411 |
+
// if carousel, use the thresholds to determine the width
|
412 |
+
}else if(slider.settings.maxSlides > 1 && slider.settings.mode == 'horizontal'){
|
413 |
+
if(wrapWidth > slider.maxThreshold){
|
414 |
+
// newElWidth = (wrapWidth - (slider.settings.slideMargin * (slider.settings.maxSlides - 1))) / slider.settings.maxSlides;
|
415 |
+
}else if(wrapWidth < slider.minThreshold){
|
416 |
+
newElWidth = (wrapWidth - (slider.settings.slideMargin * (slider.settings.minSlides - 1))) / slider.settings.minSlides;
|
417 |
+
}
|
418 |
+
}
|
419 |
+
return newElWidth;
|
420 |
+
}
|
421 |
+
|
422 |
+
/**
|
423 |
+
* Returns the number of slides currently visible in the viewport (includes partially visible slides)
|
424 |
+
*/
|
425 |
+
var getNumberSlidesShowing = function(){
|
426 |
+
var slidesShowing = 1;
|
427 |
+
if(slider.settings.mode == 'horizontal' && slider.settings.slideWidth > 0){
|
428 |
+
// if viewport is smaller than minThreshold, return minSlides
|
429 |
+
if(slider.viewport.width() < slider.minThreshold){
|
430 |
+
slidesShowing = slider.settings.minSlides;
|
431 |
+
// if viewport is larger than minThreshold, return maxSlides
|
432 |
+
}else if(slider.viewport.width() > slider.maxThreshold){
|
433 |
+
slidesShowing = slider.settings.maxSlides;
|
434 |
+
// if viewport is between min / max thresholds, divide viewport width by first child width
|
435 |
+
}else{
|
436 |
+
var childWidth = slider.children.first().width() + slider.settings.slideMargin;
|
437 |
+
slidesShowing = Math.floor((slider.viewport.width() +
|
438 |
+
slider.settings.slideMargin) / childWidth);
|
439 |
+
}
|
440 |
+
// if "vertical" mode, slides showing will always be minSlides
|
441 |
+
}else if(slider.settings.mode == 'vertical'){
|
442 |
+
slidesShowing = slider.settings.minSlides;
|
443 |
+
}
|
444 |
+
return slidesShowing;
|
445 |
+
}
|
446 |
+
|
447 |
+
/**
|
448 |
+
* Returns the number of pages (one full viewport of slides is one "page")
|
449 |
+
*/
|
450 |
+
var getPagerQty = function(){
|
451 |
+
var pagerQty = 0;
|
452 |
+
// if moveSlides is specified by the user
|
453 |
+
if(slider.settings.moveSlides > 0){
|
454 |
+
if(slider.settings.infiniteLoop){
|
455 |
+
pagerQty = Math.ceil(slider.children.length / getMoveBy());
|
456 |
+
}else{
|
457 |
+
// use a while loop to determine pages
|
458 |
+
var breakPoint = 0;
|
459 |
+
var counter = 0
|
460 |
+
// when breakpoint goes above children length, counter is the number of pages
|
461 |
+
while (breakPoint < slider.children.length){
|
462 |
+
++pagerQty;
|
463 |
+
breakPoint = counter + getNumberSlidesShowing();
|
464 |
+
counter += slider.settings.moveSlides <= getNumberSlidesShowing() ? slider.settings.moveSlides : getNumberSlidesShowing();
|
465 |
+
}
|
466 |
+
}
|
467 |
+
// if moveSlides is 0 (auto) divide children length by sides showing, then round up
|
468 |
+
}else{
|
469 |
+
pagerQty = Math.ceil(slider.children.length / getNumberSlidesShowing());
|
470 |
+
}
|
471 |
+
return pagerQty;
|
472 |
+
}
|
473 |
+
|
474 |
+
/**
|
475 |
+
* Returns the number of indivual slides by which to shift the slider
|
476 |
+
*/
|
477 |
+
var getMoveBy = function(){
|
478 |
+
// if moveSlides was set by the user and moveSlides is less than number of slides showing
|
479 |
+
if(slider.settings.moveSlides > 0 && slider.settings.moveSlides <= getNumberSlidesShowing()){
|
480 |
+
return slider.settings.moveSlides;
|
481 |
+
}
|
482 |
+
// if moveSlides is 0 (auto)
|
483 |
+
return getNumberSlidesShowing();
|
484 |
+
}
|
485 |
+
|
486 |
+
/**
|
487 |
+
* Sets the slider's (el) left or top position
|
488 |
+
*/
|
489 |
+
var setSlidePosition = function(){
|
490 |
+
// if last slide, not infinite loop, and number of children is larger than specified maxSlides
|
491 |
+
if(slider.children.length > slider.settings.maxSlides && slider.active.last && !slider.settings.infiniteLoop){
|
492 |
+
if (slider.settings.mode == 'horizontal'){
|
493 |
+
// get the last child's position
|
494 |
+
var lastChild = slider.children.last();
|
495 |
+
var position = lastChild.position();
|
496 |
+
// set the left position
|
497 |
+
setPositionProperty(-(position.left - (slider.viewport.width() - lastChild.outerWidth())), 'reset', 0);
|
498 |
+
}else if(slider.settings.mode == 'vertical'){
|
499 |
+
// get the last showing index's position
|
500 |
+
var lastShowingIndex = slider.children.length - slider.settings.minSlides;
|
501 |
+
var position = slider.children.eq(lastShowingIndex).position();
|
502 |
+
// set the top position
|
503 |
+
setPositionProperty(-position.top, 'reset', 0);
|
504 |
+
}
|
505 |
+
// if not last slide
|
506 |
+
}else{
|
507 |
+
// get the position of the first showing slide
|
508 |
+
var position = slider.children.eq(slider.active.index * getMoveBy()).position();
|
509 |
+
// check for last slide
|
510 |
+
if (slider.active.index == getPagerQty() - 1) slider.active.last = true;
|
511 |
+
// set the repective position
|
512 |
+
if (position != undefined){
|
513 |
+
if (slider.settings.mode == 'horizontal') setPositionProperty(-position.left, 'reset', 0);
|
514 |
+
else if (slider.settings.mode == 'vertical') setPositionProperty(-position.top, 'reset', 0);
|
515 |
+
}
|
516 |
+
}
|
517 |
+
}
|
518 |
+
|
519 |
+
/**
|
520 |
+
* Sets the el's animating property position (which in turn will sometimes animate el).
|
521 |
+
* If using CSS, sets the transform property. If not using CSS, sets the top / left property.
|
522 |
+
*
|
523 |
+
* @param value (int)
|
524 |
+
* - the animating property's value
|
525 |
+
*
|
526 |
+
* @param type (string) 'slider', 'reset', 'ticker'
|
527 |
+
* - the type of instance for which the function is being
|
528 |
+
*
|
529 |
+
* @param duration (int)
|
530 |
+
* - the amount of time (in ms) the transition should occupy
|
531 |
+
*
|
532 |
+
* @param params (array) optional
|
533 |
+
* - an optional parameter containing any variables that need to be passed in
|
534 |
+
*/
|
535 |
+
var setPositionProperty = function(value, type, duration, params){
|
536 |
+
// use CSS transform
|
537 |
+
if(slider.usingCSS){
|
538 |
+
// determine the translate3d value
|
539 |
+
var propValue = slider.settings.mode == 'vertical' ? 'translate3d(0, ' + value + 'px, 0)' : 'translate3d(' + value + 'px, 0, 0)';
|
540 |
+
// add the CSS transition-duration
|
541 |
+
el.css('-' + slider.cssPrefix + '-transition-duration', duration / 1000 + 's');
|
542 |
+
if(type == 'slide'){
|
543 |
+
// set the property value
|
544 |
+
el.css(slider.animProp, propValue);
|
545 |
+
// bind a callback method - executes when CSS transition completes
|
546 |
+
el.bind('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd', function(){
|
547 |
+
// unbind the callback
|
548 |
+
el.unbind('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd');
|
549 |
+
updateAfterSlideTransition();
|
550 |
+
});
|
551 |
+
}else if(type == 'reset'){
|
552 |
+
el.css(slider.animProp, propValue);
|
553 |
+
}else if(type == 'ticker'){
|
554 |
+
// make the transition use 'linear'
|
555 |
+
el.css('-' + slider.cssPrefix + '-transition-timing-function', 'linear');
|
556 |
+
el.css(slider.animProp, propValue);
|
557 |
+
// bind a callback method - executes when CSS transition completes
|
558 |
+
el.bind('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd', function(){
|
559 |
+
// unbind the callback
|
560 |
+
el.unbind('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd');
|
561 |
+
// reset the position
|
562 |
+
setPositionProperty(params['resetValue'], 'reset', 0);
|
563 |
+
// start the loop again
|
564 |
+
tickerLoop();
|
565 |
+
});
|
566 |
+
}
|
567 |
+
// use JS animate
|
568 |
+
}else{
|
569 |
+
var animateObj = {};
|
570 |
+
animateObj[slider.animProp] = value;
|
571 |
+
if(type == 'slide'){
|
572 |
+
el.animate(animateObj, duration, slider.settings.easing, function(){
|
573 |
+
updateAfterSlideTransition();
|
574 |
+
});
|
575 |
+
}else if(type == 'reset'){
|
576 |
+
el.css(slider.animProp, value)
|
577 |
+
}else if(type == 'ticker'){
|
578 |
+
el.animate(animateObj, speed, 'linear', function(){
|
579 |
+
setPositionProperty(params['resetValue'], 'reset', 0);
|
580 |
+
// run the recursive loop after animation
|
581 |
+
tickerLoop();
|
582 |
+
});
|
583 |
+
}
|
584 |
+
}
|
585 |
+
}
|
586 |
+
|
587 |
+
/**
|
588 |
+
* Populates the pager with proper amount of pages
|
589 |
+
*/
|
590 |
+
var populatePager = function(){
|
591 |
+
var pagerHtml = '';
|
592 |
+
var pagerQty = getPagerQty();
|
593 |
+
// loop through each pager item
|
594 |
+
for(var i=0; i < pagerQty; i++){
|
595 |
+
var linkContent = '';
|
596 |
+
// if a buildPager function is supplied, use it to get pager link value, else use index + 1
|
597 |
+
if(slider.settings.buildPager && $.isFunction(slider.settings.buildPager)){
|
598 |
+
linkContent = slider.settings.buildPager(i);
|
599 |
+
slider.pagerEl.addClass('bx-custom-pager');
|
600 |
+
}else{
|
601 |
+
linkContent = i + 1;
|
602 |
+
slider.pagerEl.addClass('bx-default-pager');
|
603 |
+
}
|
604 |
+
// var linkContent = slider.settings.buildPager && $.isFunction(slider.settings.buildPager) ? slider.settings.buildPager(i) : i + 1;
|
605 |
+
// add the markup to the string
|
606 |
+
pagerHtml += '<div class="bx-pager-item"><a href="" data-slide-index="' + i + '" class="bx-pager-link">' + linkContent + '</a></div>';
|
607 |
+
};
|
608 |
+
// populate the pager element with pager links
|
609 |
+
slider.pagerEl.html(pagerHtml);
|
610 |
+
}
|
611 |
+
|
612 |
+
/**
|
613 |
+
* Appends the pager to the controls element
|
614 |
+
*/
|
615 |
+
var appendPager = function(){
|
616 |
+
if(!slider.settings.pagerCustom){
|
617 |
+
// create the pager DOM element
|
618 |
+
slider.pagerEl = $('<div class="bx-pager" />');
|
619 |
+
// if a pager selector was supplied, populate it with the pager
|
620 |
+
if(slider.settings.pagerSelector){
|
621 |
+
$(slider.settings.pagerSelector).html(slider.pagerEl);
|
622 |
+
// if no pager selector was supplied, add it after the wrapper
|
623 |
+
}else{
|
624 |
+
slider.controls.el.addClass('bx-has-pager').append(slider.pagerEl);
|
625 |
+
}
|
626 |
+
// populate the pager
|
627 |
+
populatePager();
|
628 |
+
}else{
|
629 |
+
slider.pagerEl = $(slider.settings.pagerCustom);
|
630 |
+
}
|
631 |
+
// assign the pager click binding
|
632 |
+
slider.pagerEl.on('click', 'a', clickPagerBind);
|
633 |
+
}
|
634 |
+
|
635 |
+
/**
|
636 |
+
* Appends prev / next controls to the controls element
|
637 |
+
*/
|
638 |
+
var appendControls = function(){
|
639 |
+
slider.controls.next = $('<a class="bx-next" href="">' + slider.settings.nextText + '</a>');
|
640 |
+
slider.controls.prev = $('<a class="bx-prev" href="">' + slider.settings.prevText + '</a>');
|
641 |
+
// bind click actions to the controls
|
642 |
+
slider.controls.next.bind('click', clickNextBind);
|
643 |
+
slider.controls.prev.bind('click', clickPrevBind);
|
644 |
+
// if nextSlector was supplied, populate it
|
645 |
+
if(slider.settings.nextSelector){
|
646 |
+
$(slider.settings.nextSelector).append(slider.controls.next);
|
647 |
+
}
|
648 |
+
// if prevSlector was supplied, populate it
|
649 |
+
if(slider.settings.prevSelector){
|
650 |
+
$(slider.settings.prevSelector).append(slider.controls.prev);
|
651 |
+
}
|
652 |
+
// if no custom selectors were supplied
|
653 |
+
if(!slider.settings.nextSelector && !slider.settings.prevSelector){
|
654 |
+
// add the controls to the DOM
|
655 |
+
slider.controls.directionEl = $('<div class="bx-controls-direction" />');
|
656 |
+
// add the control elements to the directionEl
|
657 |
+
slider.controls.directionEl.append(slider.controls.prev).append(slider.controls.next);
|
658 |
+
// slider.viewport.append(slider.controls.directionEl);
|
659 |
+
slider.controls.el.addClass('bx-has-controls-direction').append(slider.controls.directionEl);
|
660 |
+
}
|
661 |
+
}
|
662 |
+
|
663 |
+
/**
|
664 |
+
* Appends start / stop auto controls to the controls element
|
665 |
+
*/
|
666 |
+
var appendControlsAuto = function(){
|
667 |
+
slider.controls.start = $('<div class="bx-controls-auto-item"><a class="bx-start" href="">' + slider.settings.startText + '</a></div>');
|
668 |
+
slider.controls.stop = $('<div class="bx-controls-auto-item"><a class="bx-stop" href="">' + slider.settings.stopText + '</a></div>');
|
669 |
+
// add the controls to the DOM
|
670 |
+
slider.controls.autoEl = $('<div class="bx-controls-auto" />');
|
671 |
+
// bind click actions to the controls
|
672 |
+
slider.controls.autoEl.on('click', '.bx-start', clickStartBind);
|
673 |
+
slider.controls.autoEl.on('click', '.bx-stop', clickStopBind);
|
674 |
+
// if autoControlsCombine, insert only the "start" control
|
675 |
+
if(slider.settings.autoControlsCombine){
|
676 |
+
slider.controls.autoEl.append(slider.controls.start);
|
677 |
+
// if autoControlsCombine is false, insert both controls
|
678 |
+
}else{
|
679 |
+
slider.controls.autoEl.append(slider.controls.start).append(slider.controls.stop);
|
680 |
+
}
|
681 |
+
// if auto controls selector was supplied, populate it with the controls
|
682 |
+
if(slider.settings.autoControlsSelector){
|
683 |
+
$(slider.settings.autoControlsSelector).html(slider.controls.autoEl);
|
684 |
+
// if auto controls selector was not supplied, add it after the wrapper
|
685 |
+
}else{
|
686 |
+
slider.controls.el.addClass('bx-has-controls-auto').append(slider.controls.autoEl);
|
687 |
+
}
|
688 |
+
// update the auto controls
|
689 |
+
updateAutoControls(slider.settings.autoStart ? 'stop' : 'start');
|
690 |
+
}
|
691 |
+
|
692 |
+
/**
|
693 |
+
* Appends image captions to the DOM
|
694 |
+
*/
|
695 |
+
var appendCaptions = function(){
|
696 |
+
// cycle through each child
|
697 |
+
slider.children.each(function(index){
|
698 |
+
// get the image title attribute
|
699 |
+
var title = $(this).find('img:first').attr('title');
|
700 |
+
// append the caption
|
701 |
+
if (title != undefined && ('' + title).length) {
|
702 |
+
$(this).append('<div class="bx-caption"><span>' + title + '</span></div>');
|
703 |
+
}
|
704 |
+
});
|
705 |
+
}
|
706 |
+
|
707 |
+
/**
|
708 |
+
* Click next binding
|
709 |
+
*
|
710 |
+
* @param e (event)
|
711 |
+
* - DOM event object
|
712 |
+
*/
|
713 |
+
var clickNextBind = function(e){
|
714 |
+
// if auto show is running, stop it
|
715 |
+
if (slider.settings.auto) el.stopAuto();
|
716 |
+
el.goToNextSlide();
|
717 |
+
e.preventDefault();
|
718 |
+
}
|
719 |
+
|
720 |
+
/**
|
721 |
+
* Click prev binding
|
722 |
+
*
|
723 |
+
* @param e (event)
|
724 |
+
* - DOM event object
|
725 |
+
*/
|
726 |
+
var clickPrevBind = function(e){
|
727 |
+
// if auto show is running, stop it
|
728 |
+
if (slider.settings.auto) el.stopAuto();
|
729 |
+
el.goToPrevSlide();
|
730 |
+
e.preventDefault();
|
731 |
+
}
|
732 |
+
|
733 |
+
/**
|
734 |
+
* Click start binding
|
735 |
+
*
|
736 |
+
* @param e (event)
|
737 |
+
* - DOM event object
|
738 |
+
*/
|
739 |
+
var clickStartBind = function(e){
|
740 |
+
el.startAuto();
|
741 |
+
e.preventDefault();
|
742 |
+
}
|
743 |
+
|
744 |
+
/**
|
745 |
+
* Click stop binding
|
746 |
+
*
|
747 |
+
* @param e (event)
|
748 |
+
* - DOM event object
|
749 |
+
*/
|
750 |
+
var clickStopBind = function(e){
|
751 |
+
el.stopAuto();
|
752 |
+
e.preventDefault();
|
753 |
+
}
|
754 |
+
|
755 |
+
/**
|
756 |
+
* Click pager binding
|
757 |
+
*
|
758 |
+
* @param e (event)
|
759 |
+
* - DOM event object
|
760 |
+
*/
|
761 |
+
var clickPagerBind = function(e){
|
762 |
+
// if auto show is running, stop it
|
763 |
+
if (slider.settings.auto) el.stopAuto();
|
764 |
+
var pagerLink = $(e.currentTarget);
|
765 |
+
if(pagerLink.attr('data-slide-index') !== undefined){
|
766 |
+
var pagerIndex = parseInt(pagerLink.attr('data-slide-index'));
|
767 |
+
// if clicked pager link is not active, continue with the goToSlide call
|
768 |
+
if(pagerIndex != slider.active.index) el.goToSlide(pagerIndex);
|
769 |
+
e.preventDefault();
|
770 |
+
}
|
771 |
+
}
|
772 |
+
|
773 |
+
/**
|
774 |
+
* Updates the pager links with an active class
|
775 |
+
*
|
776 |
+
* @param slideIndex (int)
|
777 |
+
* - index of slide to make active
|
778 |
+
*/
|
779 |
+
var updatePagerActive = function(slideIndex){
|
780 |
+
// if "short" pager type
|
781 |
+
var len = slider.children.length; // nb of children
|
782 |
+
if(slider.settings.pagerType == 'short'){
|
783 |
+
if(slider.settings.maxSlides > 1) {
|
784 |
+
len = Math.ceil(slider.children.length/slider.settings.maxSlides);
|
785 |
+
}
|
786 |
+
slider.pagerEl.html( (slideIndex + 1) + slider.settings.pagerShortSeparator + len);
|
787 |
+
return;
|
788 |
+
}
|
789 |
+
// remove all pager active classes
|
790 |
+
slider.pagerEl.find('a').removeClass('active');
|
791 |
+
// apply the active class for all pagers
|
792 |
+
slider.pagerEl.each(function(i, el) { $(el).find('a').eq(slideIndex).addClass('active'); });
|
793 |
+
}
|
794 |
+
|
795 |
+
/**
|
796 |
+
* Performs needed actions after a slide transition
|
797 |
+
*/
|
798 |
+
var updateAfterSlideTransition = function(){
|
799 |
+
// if infinte loop is true
|
800 |
+
if(slider.settings.infiniteLoop){
|
801 |
+
var position = '';
|
802 |
+
// first slide
|
803 |
+
if(slider.active.index == 0){
|
804 |
+
// set the new position
|
805 |
+
position = slider.children.eq(0).position();
|
806 |
+
// carousel, last slide
|
807 |
+
}else if(slider.active.index == getPagerQty() - 1 && slider.carousel){
|
808 |
+
position = slider.children.eq((getPagerQty() - 1) * getMoveBy()).position();
|
809 |
+
// last slide
|
810 |
+
}else if(slider.active.index == slider.children.length - 1){
|
811 |
+
position = slider.children.eq(slider.children.length - 1).position();
|
812 |
+
}
|
813 |
+
if(position){
|
814 |
+
if (slider.settings.mode == 'horizontal') { setPositionProperty(-position.left, 'reset', 0); }
|
815 |
+
else if (slider.settings.mode == 'vertical') { setPositionProperty(-position.top, 'reset', 0); }
|
816 |
+
}
|
817 |
+
}
|
818 |
+
// declare that the transition is complete
|
819 |
+
slider.working = false;
|
820 |
+
// onSlideAfter callback
|
821 |
+
slider.settings.onSlideAfter(slider.children.eq(slider.active.index), slider.oldIndex, slider.active.index);
|
822 |
+
}
|
823 |
+
|
824 |
+
/**
|
825 |
+
* Updates the auto controls state (either active, or combined switch)
|
826 |
+
*
|
827 |
+
* @param state (string) "start", "stop"
|
828 |
+
* - the new state of the auto show
|
829 |
+
*/
|
830 |
+
var updateAutoControls = function(state){
|
831 |
+
// if autoControlsCombine is true, replace the current control with the new state
|
832 |
+
if(slider.settings.autoControlsCombine){
|
833 |
+
slider.controls.autoEl.html(slider.controls[state]);
|
834 |
+
// if autoControlsCombine is false, apply the "active" class to the appropriate control
|
835 |
+
}else{
|
836 |
+
slider.controls.autoEl.find('a').removeClass('active');
|
837 |
+
slider.controls.autoEl.find('a:not(.bx-' + state + ')').addClass('active');
|
838 |
+
}
|
839 |
+
}
|
840 |
+
|
841 |
+
/**
|
842 |
+
* Updates the direction controls (checks if either should be hidden)
|
843 |
+
*/
|
844 |
+
var updateDirectionControls = function(){
|
845 |
+
if(getPagerQty() == 1){
|
846 |
+
slider.controls.prev.addClass('disabled');
|
847 |
+
slider.controls.next.addClass('disabled');
|
848 |
+
}else if(!slider.settings.infiniteLoop && slider.settings.hideControlOnEnd){
|
849 |
+
// if first slide
|
850 |
+
if (slider.active.index == 0){
|
851 |
+
slider.controls.prev.addClass('disabled');
|
852 |
+
slider.controls.next.removeClass('disabled');
|
853 |
+
// if last slide
|
854 |
+
}else if(slider.active.index == getPagerQty() - 1){
|
855 |
+
slider.controls.next.addClass('disabled');
|
856 |
+
slider.controls.prev.removeClass('disabled');
|
857 |
+
// if any slide in the middle
|
858 |
+
}else{
|
859 |
+
slider.controls.prev.removeClass('disabled');
|
860 |
+
slider.controls.next.removeClass('disabled');
|
861 |
+
}
|
862 |
+
}
|
863 |
+
}
|
864 |
+
|
865 |
+
/**
|
866 |
+
* Initialzes the auto process
|
867 |
+
*/
|
868 |
+
var initAuto = function(){
|
869 |
+
// if autoDelay was supplied, launch the auto show using a setTimeout() call
|
870 |
+
if(slider.settings.autoDelay > 0){
|
871 |
+
var timeout = setTimeout(el.startAuto, slider.settings.autoDelay);
|
872 |
+
// if autoDelay was not supplied, start the auto show normally
|
873 |
+
}else{
|
874 |
+
el.startAuto();
|
875 |
+
}
|
876 |
+
// if autoHover is requested
|
877 |
+
if(slider.settings.autoHover){
|
878 |
+
// on el hover
|
879 |
+
el.hover(function(){
|
880 |
+
// if the auto show is currently playing (has an active interval)
|
881 |
+
if(slider.interval){
|
882 |
+
// stop the auto show and pass true agument which will prevent control update
|
883 |
+
el.stopAuto(true);
|
884 |
+
// create a new autoPaused value which will be used by the relative "mouseout" event
|
885 |
+
slider.autoPaused = true;
|
886 |
+
}
|
887 |
+
}, function(){
|
888 |
+
// if the autoPaused value was created be the prior "mouseover" event
|
889 |
+
if(slider.autoPaused){
|
890 |
+
// start the auto show and pass true agument which will prevent control update
|
891 |
+
el.startAuto(true);
|
892 |
+
// reset the autoPaused value
|
893 |
+
slider.autoPaused = null;
|
894 |
+
}
|
895 |
+
});
|
896 |
+
}
|
897 |
+
}
|
898 |
+
|
899 |
+
/**
|
900 |
+
* Initialzes the ticker process
|
901 |
+
*/
|
902 |
+
var initTicker = function(){
|
903 |
+
var startPosition = 0;
|
904 |
+
// if autoDirection is "next", append a clone of the entire slider
|
905 |
+
if(slider.settings.autoDirection == 'next'){
|
906 |
+
el.append(slider.children.clone().addClass('bx-clone'));
|
907 |
+
// if autoDirection is "prev", prepend a clone of the entire slider, and set the left position
|
908 |
+
}else{
|
909 |
+
el.prepend(slider.children.clone().addClass('bx-clone'));
|
910 |
+
var position = slider.children.first().position();
|
911 |
+
startPosition = slider.settings.mode == 'horizontal' ? -position.left : -position.top;
|
912 |
+
}
|
913 |
+
setPositionProperty(startPosition, 'reset', 0);
|
914 |
+
// do not allow controls in ticker mode
|
915 |
+
slider.settings.pager = false;
|
916 |
+
slider.settings.controls = false;
|
917 |
+
slider.settings.autoControls = false;
|
918 |
+
// if autoHover is requested
|
919 |
+
if(slider.settings.tickerHover && !slider.usingCSS){
|
920 |
+
// on el hover
|
921 |
+
slider.viewport.hover(function(){
|
922 |
+
el.stop();
|
923 |
+
}, function(){
|
924 |
+
// calculate the total width of children (used to calculate the speed ratio)
|
925 |
+
var totalDimens = 0;
|
926 |
+
slider.children.each(function(index){
|
927 |
+
totalDimens += slider.settings.mode == 'horizontal' ? $(this).outerWidth(true) : $(this).outerHeight(true);
|
928 |
+
});
|
929 |
+
// calculate the speed ratio (used to determine the new speed to finish the paused animation)
|
930 |
+
var ratio = slider.settings.speed / totalDimens;
|
931 |
+
// determine which property to use
|
932 |
+
var property = slider.settings.mode == 'horizontal' ? 'left' : 'top';
|
933 |
+
// calculate the new speed
|
934 |
+
var newSpeed = ratio * (totalDimens - (Math.abs(parseInt(el.css(property)))));
|
935 |
+
tickerLoop(newSpeed);
|
936 |
+
});
|
937 |
+
}
|
938 |
+
// start the ticker loop
|
939 |
+
tickerLoop();
|
940 |
+
}
|
941 |
+
|
942 |
+
/**
|
943 |
+
* Runs a continuous loop, news ticker-style
|
944 |
+
*/
|
945 |
+
var tickerLoop = function(resumeSpeed){
|
946 |
+
speed = resumeSpeed ? resumeSpeed : slider.settings.speed;
|
947 |
+
var position = {left: 0, top: 0};
|
948 |
+
var reset = {left: 0, top: 0};
|
949 |
+
// if "next" animate left position to last child, then reset left to 0
|
950 |
+
if(slider.settings.autoDirection == 'next'){
|
951 |
+
position = el.find('.bx-clone').first().position();
|
952 |
+
// if "prev" animate left position to 0, then reset left to first non-clone child
|
953 |
+
}else{
|
954 |
+
reset = slider.children.first().position();
|
955 |
+
}
|
956 |
+
var animateProperty = slider.settings.mode == 'horizontal' ? -position.left : -position.top;
|
957 |
+
var resetValue = slider.settings.mode == 'horizontal' ? -reset.left : -reset.top;
|
958 |
+
var params = {resetValue: resetValue};
|
959 |
+
setPositionProperty(animateProperty, 'ticker', speed, params);
|
960 |
+
}
|
961 |
+
|
962 |
+
/**
|
963 |
+
* Initializes touch events
|
964 |
+
*/
|
965 |
+
var initTouch = function(){
|
966 |
+
// initialize object to contain all touch values
|
967 |
+
slider.touch = {
|
968 |
+
start: {x: 0, y: 0},
|
969 |
+
end: {x: 0, y: 0}
|
970 |
+
}
|
971 |
+
slider.viewport.bind('touchstart', onTouchStart);
|
972 |
+
}
|
973 |
+
|
974 |
+
/**
|
975 |
+
* Event handler for "touchstart"
|
976 |
+
*
|
977 |
+
* @param e (event)
|
978 |
+
* - DOM event object
|
979 |
+
*/
|
980 |
+
var onTouchStart = function(e){
|
981 |
+
if(slider.working){
|
982 |
+
e.preventDefault();
|
983 |
+
}else{
|
984 |
+
// record the original position when touch starts
|
985 |
+
slider.touch.originalPos = el.position();
|
986 |
+
var orig = e.originalEvent;
|
987 |
+
// record the starting touch x, y coordinates
|
988 |
+
slider.touch.start.x = orig.changedTouches[0].pageX;
|
989 |
+
slider.touch.start.y = orig.changedTouches[0].pageY;
|
990 |
+
// bind a "touchmove" event to the viewport
|
991 |
+
slider.viewport.bind('touchmove', onTouchMove);
|
992 |
+
// bind a "touchend" event to the viewport
|
993 |
+
slider.viewport.bind('touchend', onTouchEnd);
|
994 |
+
}
|
995 |
+
}
|
996 |
+
|
997 |
+
/**
|
998 |
+
* Event handler for "touchmove"
|
999 |
+
*
|
1000 |
+
* @param e (event)
|
1001 |
+
* - DOM event object
|
1002 |
+
*/
|
1003 |
+
var onTouchMove = function(e){
|
1004 |
+
var orig = e.originalEvent;
|
1005 |
+
// if scrolling on y axis, do not prevent default
|
1006 |
+
var xMovement = Math.abs(orig.changedTouches[0].pageX - slider.touch.start.x);
|
1007 |
+
var yMovement = Math.abs(orig.changedTouches[0].pageY - slider.touch.start.y);
|
1008 |
+
// x axis swipe
|
1009 |
+
if((xMovement * 3) > yMovement && slider.settings.preventDefaultSwipeX){
|
1010 |
+
e.preventDefault();
|
1011 |
+
// y axis swipe
|
1012 |
+
}else if((yMovement * 3) > xMovement && slider.settings.preventDefaultSwipeY){
|
1013 |
+
e.preventDefault();
|
1014 |
+
}
|
1015 |
+
if(slider.settings.mode != 'fade' && slider.settings.oneToOneTouch){
|
1016 |
+
var value = 0;
|
1017 |
+
// if horizontal, drag along x axis
|
1018 |
+
if(slider.settings.mode == 'horizontal'){
|
1019 |
+
var change = orig.changedTouches[0].pageX - slider.touch.start.x;
|
1020 |
+
value = slider.touch.originalPos.left + change;
|
1021 |
+
// if vertical, drag along y axis
|
1022 |
+
}else{
|
1023 |
+
var change = orig.changedTouches[0].pageY - slider.touch.start.y;
|
1024 |
+
value = slider.touch.originalPos.top + change;
|
1025 |
+
}
|
1026 |
+
setPositionProperty(value, 'reset', 0);
|
1027 |
+
}
|
1028 |
+
}
|
1029 |
+
|
1030 |
+
/**
|
1031 |
+
* Event handler for "touchend"
|
1032 |
+
*
|
1033 |
+
* @param e (event)
|
1034 |
+
* - DOM event object
|
1035 |
+
*/
|
1036 |
+
var onTouchEnd = function(e){
|
1037 |
+
slider.viewport.unbind('touchmove', onTouchMove);
|
1038 |
+
var orig = e.originalEvent;
|
1039 |
+
var value = 0;
|
1040 |
+
// record end x, y positions
|
1041 |
+
slider.touch.end.x = orig.changedTouches[0].pageX;
|
1042 |
+
slider.touch.end.y = orig.changedTouches[0].pageY;
|
1043 |
+
// if fade mode, check if absolute x distance clears the threshold
|
1044 |
+
if(slider.settings.mode == 'fade'){
|
1045 |
+
var distance = Math.abs(slider.touch.start.x - slider.touch.end.x);
|
1046 |
+
if(distance >= slider.settings.swipeThreshold){
|
1047 |
+
slider.touch.start.x > slider.touch.end.x ? el.goToNextSlide() : el.goToPrevSlide();
|
1048 |
+
el.stopAuto();
|
1049 |
+
}
|
1050 |
+
// not fade mode
|
1051 |
+
}else{
|
1052 |
+
var distance = 0;
|
1053 |
+
// calculate distance and el's animate property
|
1054 |
+
if(slider.settings.mode == 'horizontal'){
|
1055 |
+
distance = slider.touch.end.x - slider.touch.start.x;
|
1056 |
+
value = slider.touch.originalPos.left;
|
1057 |
+
}else{
|
1058 |
+
distance = slider.touch.end.y - slider.touch.start.y;
|
1059 |
+
value = slider.touch.originalPos.top;
|
1060 |
+
}
|
1061 |
+
// if not infinite loop and first / last slide, do not attempt a slide transition
|
1062 |
+
if(!slider.settings.infiniteLoop && ((slider.active.index == 0 && distance > 0) || (slider.active.last && distance < 0))){
|
1063 |
+
setPositionProperty(value, 'reset', 200);
|
1064 |
+
}else{
|
1065 |
+
// check if distance clears threshold
|
1066 |
+
if(Math.abs(distance) >= slider.settings.swipeThreshold){
|
1067 |
+
distance < 0 ? el.goToNextSlide() : el.goToPrevSlide();
|
1068 |
+
el.stopAuto();
|
1069 |
+
}else{
|
1070 |
+
// el.animate(property, 200);
|
1071 |
+
setPositionProperty(value, 'reset', 200);
|
1072 |
+
}
|
1073 |
+
}
|
1074 |
+
}
|
1075 |
+
slider.viewport.unbind('touchend', onTouchEnd);
|
1076 |
+
}
|
1077 |
+
|
1078 |
+
/**
|
1079 |
+
* Window resize event callback
|
1080 |
+
*/
|
1081 |
+
var resizeWindow = function(e){
|
1082 |
+
// don't do anything if slider isn't initialized.
|
1083 |
+
if(!slider.initialized) return;
|
1084 |
+
// get the new window dimens (again, thank you IE)
|
1085 |
+
var windowWidthNew = $(window).width();
|
1086 |
+
var windowHeightNew = $(window).height();
|
1087 |
+
// make sure that it is a true window resize
|
1088 |
+
// *we must check this because our dinosaur friend IE fires a window resize event when certain DOM elements
|
1089 |
+
// are resized. Can you just die already?*
|
1090 |
+
if(windowWidth != windowWidthNew || windowHeight != windowHeightNew){
|
1091 |
+
// set the new window dimens
|
1092 |
+
windowWidth = windowWidthNew;
|
1093 |
+
windowHeight = windowHeightNew;
|
1094 |
+
// update all dynamic elements
|
1095 |
+
el.redrawSlider();
|
1096 |
+
// Call user resize handler
|
1097 |
+
slider.settings.onSliderResize.call(el, slider.active.index);
|
1098 |
+
}
|
1099 |
+
}
|
1100 |
+
|
1101 |
+
/**
|
1102 |
+
* ===================================================================================
|
1103 |
+
* = PUBLIC FUNCTIONS
|
1104 |
+
* ===================================================================================
|
1105 |
+
*/
|
1106 |
+
|
1107 |
+
/**
|
1108 |
+
* Performs slide transition to the specified slide
|
1109 |
+
*
|
1110 |
+
* @param slideIndex (int)
|
1111 |
+
* - the destination slide's index (zero-based)
|
1112 |
+
*
|
1113 |
+
* @param direction (string)
|
1114 |
+
* - INTERNAL USE ONLY - the direction of travel ("prev" / "next")
|
1115 |
+
*/
|
1116 |
+
el.goToSlide = function(slideIndex, direction){
|
1117 |
+
// if plugin is currently in motion, ignore request
|
1118 |
+
if(slider.working || slider.active.index == slideIndex) return;
|
1119 |
+
// declare that plugin is in motion
|
1120 |
+
slider.working = true;
|
1121 |
+
// store the old index
|
1122 |
+
slider.oldIndex = slider.active.index;
|
1123 |
+
// if slideIndex is less than zero, set active index to last child (this happens during infinite loop)
|
1124 |
+
if(slideIndex < 0){
|
1125 |
+
slider.active.index = getPagerQty() - 1;
|
1126 |
+
// if slideIndex is greater than children length, set active index to 0 (this happens during infinite loop)
|
1127 |
+
}else if(slideIndex >= getPagerQty()){
|
1128 |
+
slider.active.index = 0;
|
1129 |
+
// set active index to requested slide
|
1130 |
+
}else{
|
1131 |
+
slider.active.index = slideIndex;
|
1132 |
+
}
|
1133 |
+
// onSlideBefore, onSlideNext, onSlidePrev callbacks
|
1134 |
+
slider.settings.onSlideBefore(slider.children.eq(slider.active.index), slider.oldIndex, slider.active.index);
|
1135 |
+
if(direction == 'next'){
|
1136 |
+
slider.settings.onSlideNext(slider.children.eq(slider.active.index), slider.oldIndex, slider.active.index);
|
1137 |
+
}else if(direction == 'prev'){
|
1138 |
+
slider.settings.onSlidePrev(slider.children.eq(slider.active.index), slider.oldIndex, slider.active.index);
|
1139 |
+
}
|
1140 |
+
// check if last slide
|
1141 |
+
slider.active.last = slider.active.index >= getPagerQty() - 1;
|
1142 |
+
// update the pager with active class
|
1143 |
+
if(slider.settings.pager) updatePagerActive(slider.active.index);
|
1144 |
+
// // check for direction control update
|
1145 |
+
if(slider.settings.controls) updateDirectionControls();
|
1146 |
+
// if slider is set to mode: "fade"
|
1147 |
+
if(slider.settings.mode == 'fade'){
|
1148 |
+
// if adaptiveHeight is true and next height is different from current height, animate to the new height
|
1149 |
+
if(slider.settings.adaptiveHeight && slider.viewport.height() != getViewportHeight()){
|
1150 |
+
slider.viewport.animate({height: getViewportHeight()}, slider.settings.adaptiveHeightSpeed);
|
1151 |
+
}
|
1152 |
+
// fade out the visible child and reset its z-index value
|
1153 |
+
slider.children.filter(':visible').fadeOut(slider.settings.speed).css({zIndex: 0});
|
1154 |
+
// fade in the newly requested slide
|
1155 |
+
slider.children.eq(slider.active.index).css('zIndex', slider.settings.slideZIndex+1).fadeIn(slider.settings.speed, function(){
|
1156 |
+
$(this).css('zIndex', slider.settings.slideZIndex);
|
1157 |
+
updateAfterSlideTransition();
|
1158 |
+
});
|
1159 |
+
// slider mode is not "fade"
|
1160 |
+
}else{
|
1161 |
+
// if adaptiveHeight is true and next height is different from current height, animate to the new height
|
1162 |
+
if(slider.settings.adaptiveHeight && slider.viewport.height() != getViewportHeight()){
|
1163 |
+
slider.viewport.animate({height: getViewportHeight()}, slider.settings.adaptiveHeightSpeed);
|
1164 |
+
}
|
1165 |
+
var moveBy = 0;
|
1166 |
+
var position = {left: 0, top: 0};
|
1167 |
+
// if carousel and not infinite loop
|
1168 |
+
if(!slider.settings.infiniteLoop && slider.carousel && slider.active.last){
|
1169 |
+
if(slider.settings.mode == 'horizontal'){
|
1170 |
+
// get the last child position
|
1171 |
+
var lastChild = slider.children.eq(slider.children.length - 1);
|
1172 |
+
position = lastChild.position();
|
1173 |
+
// calculate the position of the last slide
|
1174 |
+
moveBy = slider.viewport.width() - lastChild.outerWidth();
|
1175 |
+
}else{
|
1176 |
+
// get last showing index position
|
1177 |
+
var lastShowingIndex = slider.children.length - slider.settings.minSlides;
|
1178 |
+
position = slider.children.eq(lastShowingIndex).position();
|
1179 |
+
}
|
1180 |
+
// horizontal carousel, going previous while on first slide (infiniteLoop mode)
|
1181 |
+
}else if(slider.carousel && slider.active.last && direction == 'prev'){
|
1182 |
+
// get the last child position
|
1183 |
+
var eq = slider.settings.moveSlides == 1 ? slider.settings.maxSlides - getMoveBy() : ((getPagerQty() - 1) * getMoveBy()) - (slider.children.length - slider.settings.maxSlides);
|
1184 |
+
var lastChild = el.children('.bx-clone').eq(eq);
|
1185 |
+
position = lastChild.position();
|
1186 |
+
// if infinite loop and "Next" is clicked on the last slide
|
1187 |
+
}else if(direction == 'next' && slider.active.index == 0){
|
1188 |
+
// get the last clone position
|
1189 |
+
position = el.find('> .bx-clone').eq(slider.settings.maxSlides).position();
|
1190 |
+
slider.active.last = false;
|
1191 |
+
// normal non-zero requests
|
1192 |
+
}else if(slideIndex >= 0){
|
1193 |
+
var requestEl = slideIndex * getMoveBy();
|
1194 |
+
position = slider.children.eq(requestEl).position();
|
1195 |
+
}
|
1196 |
+
|
1197 |
+
/* If the position doesn't exist
|
1198 |
+
* (e.g. if you destroy the slider on a next click),
|
1199 |
+
* it doesn't throw an error.
|
1200 |
+
*/
|
1201 |
+
if ("undefined" !== typeof(position)) {
|
1202 |
+
var value = slider.settings.mode == 'horizontal' ? -(position.left - moveBy) : -position.top;
|
1203 |
+
// plugin values to be animated
|
1204 |
+
setPositionProperty(value, 'slide', slider.settings.speed);
|
1205 |
+
}
|
1206 |
+
}
|
1207 |
+
}
|
1208 |
+
|
1209 |
+
/**
|
1210 |
+
* Transitions to the next slide in the show
|
1211 |
+
*/
|
1212 |
+
el.goToNextSlide = function(){
|
1213 |
+
// if infiniteLoop is false and last page is showing, disregard call
|
1214 |
+
if (!slider.settings.infiniteLoop && slider.active.last) return;
|
1215 |
+
var pagerIndex = parseInt(slider.active.index) + 1;
|
1216 |
+
el.goToSlide(pagerIndex, 'next');
|
1217 |
+
}
|
1218 |
+
|
1219 |
+
/**
|
1220 |
+
* Transitions to the prev slide in the show
|
1221 |
+
*/
|
1222 |
+
el.goToPrevSlide = function(){
|
1223 |
+
// if infiniteLoop is false and last page is showing, disregard call
|
1224 |
+
if (!slider.settings.infiniteLoop && slider.active.index == 0) return;
|
1225 |
+
var pagerIndex = parseInt(slider.active.index) - 1;
|
1226 |
+
el.goToSlide(pagerIndex, 'prev');
|
1227 |
+
}
|
1228 |
+
|
1229 |
+
/**
|
1230 |
+
* Starts the auto show
|
1231 |
+
*
|
1232 |
+
* @param preventControlUpdate (boolean)
|
1233 |
+
* - if true, auto controls state will not be updated
|
1234 |
+
*/
|
1235 |
+
el.startAuto = function(preventControlUpdate){
|
1236 |
+
// if an interval already exists, disregard call
|
1237 |
+
if(slider.interval) return;
|
1238 |
+
// create an interval
|
1239 |
+
slider.interval = setInterval(function(){
|
1240 |
+
slider.settings.autoDirection == 'next' ? el.goToNextSlide() : el.goToPrevSlide();
|
1241 |
+
}, slider.settings.pause);
|
1242 |
+
// if auto controls are displayed and preventControlUpdate is not true
|
1243 |
+
if (slider.settings.autoControls && preventControlUpdate != true) updateAutoControls('stop');
|
1244 |
+
}
|
1245 |
+
|
1246 |
+
/**
|
1247 |
+
* Stops the auto show
|
1248 |
+
*
|
1249 |
+
* @param preventControlUpdate (boolean)
|
1250 |
+
* - if true, auto controls state will not be updated
|
1251 |
+
*/
|
1252 |
+
el.stopAuto = function(preventControlUpdate){
|
1253 |
+
// if no interval exists, disregard call
|
1254 |
+
if(!slider.interval) return;
|
1255 |
+
// clear the interval
|
1256 |
+
clearInterval(slider.interval);
|
1257 |
+
slider.interval = null;
|
1258 |
+
// if auto controls are displayed and preventControlUpdate is not true
|
1259 |
+
if (slider.settings.autoControls && preventControlUpdate != true) updateAutoControls('start');
|
1260 |
+
}
|
1261 |
+
|
1262 |
+
/**
|
1263 |
+
* Returns current slide index (zero-based)
|
1264 |
+
*/
|
1265 |
+
el.getCurrentSlide = function(){
|
1266 |
+
return slider.active.index;
|
1267 |
+
}
|
1268 |
+
|
1269 |
+
/**
|
1270 |
+
* Returns current slide element
|
1271 |
+
*/
|
1272 |
+
el.getCurrentSlideElement = function(){
|
1273 |
+
return slider.children.eq(slider.active.index);
|
1274 |
+
}
|
1275 |
+
|
1276 |
+
/**
|
1277 |
+
* Returns number of slides in show
|
1278 |
+
*/
|
1279 |
+
el.getSlideCount = function(){
|
1280 |
+
return slider.children.length;
|
1281 |
+
}
|
1282 |
+
|
1283 |
+
/**
|
1284 |
+
* Update all dynamic slider elements
|
1285 |
+
*/
|
1286 |
+
el.redrawSlider = function(){
|
1287 |
+
// resize all children in ratio to new screen size
|
1288 |
+
slider.children.add(el.find('.bx-clone')).width(getSlideWidth());
|
1289 |
+
// adjust the height
|
1290 |
+
slider.viewport.css('height', getViewportHeight());
|
1291 |
+
// update the slide position
|
1292 |
+
if(!slider.settings.ticker) setSlidePosition();
|
1293 |
+
// if active.last was true before the screen resize, we want
|
1294 |
+
// to keep it last no matter what screen size we end on
|
1295 |
+
if (slider.active.last) slider.active.index = getPagerQty() - 1;
|
1296 |
+
// if the active index (page) no longer exists due to the resize, simply set the index as last
|
1297 |
+
if (slider.active.index >= getPagerQty()) slider.active.last = true;
|
1298 |
+
// if a pager is being displayed and a custom pager is not being used, update it
|
1299 |
+
if(slider.settings.pager && !slider.settings.pagerCustom){
|
1300 |
+
populatePager();
|
1301 |
+
updatePagerActive(slider.active.index);
|
1302 |
+
}
|
1303 |
+
}
|
1304 |
+
|
1305 |
+
/**
|
1306 |
+
* Destroy the current instance of the slider (revert everything back to original state)
|
1307 |
+
*/
|
1308 |
+
el.destroySlider = function(){
|
1309 |
+
// don't do anything if slider has already been destroyed
|
1310 |
+
if(!slider.initialized) return;
|
1311 |
+
slider.initialized = false;
|
1312 |
+
$('.bx-clone', this).remove();
|
1313 |
+
slider.children.each(function() {
|
1314 |
+
$(this).data("origStyle") != undefined ? $(this).attr("style", $(this).data("origStyle")) : $(this).removeAttr('style');
|
1315 |
+
});
|
1316 |
+
$(this).data("origStyle") != undefined ? this.attr("style", $(this).data("origStyle")) : $(this).removeAttr('style');
|
1317 |
+
$(this).unwrap().unwrap();
|
1318 |
+
if(slider.controls.el) slider.controls.el.remove();
|
1319 |
+
if(slider.controls.next) slider.controls.next.remove();
|
1320 |
+
if(slider.controls.prev) slider.controls.prev.remove();
|
1321 |
+
if(slider.pagerEl && slider.settings.controls) slider.pagerEl.remove();
|
1322 |
+
$('.bx-caption', this).remove();
|
1323 |
+
if(slider.controls.autoEl) slider.controls.autoEl.remove();
|
1324 |
+
clearInterval(slider.interval);
|
1325 |
+
if(slider.settings.responsive) $(window).unbind('resize', resizeWindow);
|
1326 |
+
}
|
1327 |
+
|
1328 |
+
/**
|
1329 |
+
* Reload the slider (revert all DOM changes, and re-initialize)
|
1330 |
+
*/
|
1331 |
+
el.reloadSlider = function(settings){
|
1332 |
+
if (settings != undefined) options = settings;
|
1333 |
+
el.destroySlider();
|
1334 |
+
init();
|
1335 |
+
}
|
1336 |
+
|
1337 |
+
init();
|
1338 |
+
|
1339 |
+
// returns the current jQuery object
|
1340 |
+
return this;
|
1341 |
+
}
|
1342 |
+
|
1343 |
+
})(jQuery);
|
skin/frontend/base/default/js/srdt/jquery.bxslider.min.js
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* BxSlider v4.1.2 - Fully loaded, responsive content slider
|
3 |
+
* http://bxslider.com
|
4 |
+
*
|
5 |
+
* Copyright 2014, Steven Wanderski - http://stevenwanderski.com - http://bxcreative.com
|
6 |
+
* Written while drinking Belgian ales and listening to jazz
|
7 |
+
*
|
8 |
+
* Released under the MIT license - http://opensource.org/licenses/MIT
|
9 |
+
*/
|
10 |
+
!function(t){var e={},s={mode:"horizontal",slideSelector:"",infiniteLoop:!0,hideControlOnEnd:!1,speed:500,easing:null,slideMargin:0,startSlide:0,randomStart:!1,captions:!1,ticker:!1,tickerHover:!1,adaptiveHeight:!1,adaptiveHeightSpeed:500,video:!1,useCSS:!0,preloadImages:"visible",responsive:!0,slideZIndex:50,touchEnabled:!0,swipeThreshold:50,oneToOneTouch:!0,preventDefaultSwipeX:!0,preventDefaultSwipeY:!1,pager:!0,pagerType:"full",pagerShortSeparator:" / ",pagerSelector:null,buildPager:null,pagerCustom:null,controls:!0,nextText:"Next",prevText:"Prev",nextSelector:null,prevSelector:null,autoControls:!1,startText:"Start",stopText:"Stop",autoControlsCombine:!1,autoControlsSelector:null,auto:!1,pause:4e3,autoStart:!0,autoDirection:"next",autoHover:!1,autoDelay:0,minSlides:1,maxSlides:1,moveSlides:0,slideWidth:0,onSliderLoad:function(){},onSlideBefore:function(){},onSlideAfter:function(){},onSlideNext:function(){},onSlidePrev:function(){},onSliderResize:function(){}};t.fn.bxSlider=function(n){if(0==this.length)return this;if(this.length>1)return this.each(function(){t(this).bxSlider(n)}),this;var o={},r=this;e.el=this;var a=t(window).width(),l=t(window).height(),d=function(){o.settings=t.extend({},s,n),o.settings.slideWidth=parseInt(o.settings.slideWidth),o.children=r.children(o.settings.slideSelector),o.children.length<o.settings.minSlides&&(o.settings.minSlides=o.children.length),o.children.length<o.settings.maxSlides&&(o.settings.maxSlides=o.children.length),o.settings.randomStart&&(o.settings.startSlide=Math.floor(Math.random()*o.children.length)),o.active={index:o.settings.startSlide},o.carousel=o.settings.minSlides>1||o.settings.maxSlides>1,o.carousel&&(o.settings.preloadImages="all"),o.minThreshold=o.settings.minSlides*o.settings.slideWidth+(o.settings.minSlides-1)*o.settings.slideMargin,o.maxThreshold=o.settings.maxSlides*o.settings.slideWidth+(o.settings.maxSlides-1)*o.settings.slideMargin,o.working=!1,o.controls={},o.interval=null,o.animProp="vertical"==o.settings.mode?"top":"left",o.usingCSS=o.settings.useCSS&&"fade"!=o.settings.mode&&function(){var t=document.createElement("div"),e=["WebkitPerspective","MozPerspective","OPerspective","msPerspective"];for(var i in e)if(void 0!==t.style[e[i]])return o.cssPrefix=e[i].replace("Perspective","").toLowerCase(),o.animProp="-"+o.cssPrefix+"-transform",!0;return!1}(),"vertical"==o.settings.mode&&(o.settings.maxSlides=o.settings.minSlides),r.data("origStyle",r.attr("style")),r.children(o.settings.slideSelector).each(function(){t(this).data("origStyle",t(this).attr("style"))}),c()},c=function(){r.wrap('<div class="bx-wrapper"><div class="bx-viewport"></div></div>'),o.viewport=r.parent(),o.loader=t('<div class="bx-loading" />'),o.viewport.prepend(o.loader),r.css({width:"horizontal"==o.settings.mode?100*o.children.length+215+"%":"auto",position:"relative"}),o.usingCSS&&o.settings.easing?r.css("-"+o.cssPrefix+"-transition-timing-function",o.settings.easing):o.settings.easing||(o.settings.easing="swing"),f(),o.viewport.css({width:"100%",overflow:"hidden",position:"relative"}),o.viewport.parent().css({maxWidth:p()}),o.settings.pager||o.viewport.parent().css({margin:"0 auto 0px"}),o.children.css({"float":"horizontal"==o.settings.mode?"left":"none",listStyle:"none",position:"relative"}),o.children.css("width",u()),"horizontal"==o.settings.mode&&o.settings.slideMargin>0&&o.children.css("marginRight",o.settings.slideMargin),"vertical"==o.settings.mode&&o.settings.slideMargin>0&&o.children.css("marginBottom",o.settings.slideMargin),"fade"==o.settings.mode&&(o.children.css({position:"absolute",zIndex:0,display:"none"}),o.children.eq(o.settings.startSlide).css({zIndex:o.settings.slideZIndex,display:"block"})),o.controls.el=t('<div class="bx-controls" />'),o.settings.captions&&P(),o.active.last=o.settings.startSlide==x()-1,o.settings.video&&r.fitVids();var e=o.children.eq(o.settings.startSlide);"all"==o.settings.preloadImages&&(e=o.children),o.settings.ticker?o.settings.pager=!1:(o.settings.pager&&T(),o.settings.controls&&C(),o.settings.auto&&o.settings.autoControls&&E(),(o.settings.controls||o.settings.autoControls||o.settings.pager)&&o.viewport.after(o.controls.el)),g(e,h)},g=function(e,i){var s=e.find("img, iframe").length;if(0==s)return i(),void 0;var n=0;e.find("img, iframe").each(function(){t(this).one("load",function(){++n==s&&i()}).each(function(){this.complete&&t(this).load()})})},h=function(){if(o.settings.infiniteLoop&&"fade"!=o.settings.mode&&!o.settings.ticker){var e="vertical"==o.settings.mode?o.settings.minSlides:o.settings.maxSlides,i=o.children.slice(0,e).clone().addClass("bx-clone"),s=o.children.slice(-e).clone().addClass("bx-clone");r.append(i).prepend(s)}o.loader.remove(),S(),"vertical"==o.settings.mode&&(o.settings.adaptiveHeight=!0),o.viewport.height(v()),r.redrawSlider(),o.settings.onSliderLoad(o.active.index),o.initialized=!0,o.settings.responsive&&t(window).bind("resize",Z),o.settings.auto&&o.settings.autoStart&&H(),o.settings.ticker&&L(),o.settings.pager&&q(o.settings.startSlide),o.settings.controls&&W(),o.settings.touchEnabled&&!o.settings.ticker&&O()},v=function(){var e=0,s=t();if("vertical"==o.settings.mode||o.settings.adaptiveHeight)if(o.carousel){var n=1==o.settings.moveSlides?o.active.index:o.active.index*m();for(s=o.children.eq(n),i=1;i<=o.settings.maxSlides-1;i++)s=n+i>=o.children.length?s.add(o.children.eq(i-1)):s.add(o.children.eq(n+i))}else s=o.children.eq(o.active.index);else s=o.children;return"vertical"==o.settings.mode?(s.each(function(){e+=t(this).outerHeight()}),o.settings.slideMargin>0&&(e+=o.settings.slideMargin*(o.settings.minSlides-1))):e=Math.max.apply(Math,s.map(function(){return t(this).outerHeight(!1)}).get()),e},p=function(){var t="100%";return o.settings.slideWidth>0&&(t="horizontal"==o.settings.mode?o.settings.maxSlides*o.settings.slideWidth+(o.settings.maxSlides-1)*o.settings.slideMargin:o.settings.slideWidth),t},u=function(){var t=o.settings.slideWidth,e=o.viewport.width();return 0==o.settings.slideWidth||o.settings.slideWidth>e&&!o.carousel||"vertical"==o.settings.mode?t=e:o.settings.maxSlides>1&&"horizontal"==o.settings.mode&&(e>o.maxThreshold||e<o.minThreshold&&(t=(e-o.settings.slideMargin*(o.settings.minSlides-1))/o.settings.minSlides)),t},f=function(){var t=1;if("horizontal"==o.settings.mode&&o.settings.slideWidth>0)if(o.viewport.width()<o.minThreshold)t=o.settings.minSlides;else if(o.viewport.width()>o.maxThreshold)t=o.settings.maxSlides;else{var e=o.children.first().width();t=Math.floor(o.viewport.width()/e)}else"vertical"==o.settings.mode&&(t=o.settings.minSlides);return t},x=function(){var t=0;if(o.settings.moveSlides>0)if(o.settings.infiniteLoop)t=o.children.length/m();else for(var e=0,i=0;e<o.children.length;)++t,e=i+f(),i+=o.settings.moveSlides<=f()?o.settings.moveSlides:f();else t=Math.ceil(o.children.length/f());return t},m=function(){return o.settings.moveSlides>0&&o.settings.moveSlides<=f()?o.settings.moveSlides:f()},S=function(){if(o.children.length>o.settings.maxSlides&&o.active.last&&!o.settings.infiniteLoop){if("horizontal"==o.settings.mode){var t=o.children.last(),e=t.position();b(-(e.left-(o.viewport.width()-t.width())),"reset",0)}else if("vertical"==o.settings.mode){var i=o.children.length-o.settings.minSlides,e=o.children.eq(i).position();b(-e.top,"reset",0)}}else{var e=o.children.eq(o.active.index*m()).position();o.active.index==x()-1&&(o.active.last=!0),void 0!=e&&("horizontal"==o.settings.mode?b(-e.left,"reset",0):"vertical"==o.settings.mode&&b(-e.top,"reset",0))}},b=function(t,e,i,s){if(o.usingCSS){var n="vertical"==o.settings.mode?"translate3d(0, "+t+"px, 0)":"translate3d("+t+"px, 0, 0)";r.css("-"+o.cssPrefix+"-transition-duration",i/1e3+"s"),"slide"==e?(r.css(o.animProp,n),r.bind("transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd",function(){r.unbind("transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd"),D()})):"reset"==e?r.css(o.animProp,n):"ticker"==e&&(r.css("-"+o.cssPrefix+"-transition-timing-function","linear"),r.css(o.animProp,n),r.bind("transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd",function(){r.unbind("transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd"),b(s.resetValue,"reset",0),N()}))}else{var a={};a[o.animProp]=t,"slide"==e?r.animate(a,i,o.settings.easing,function(){D()}):"reset"==e?r.css(o.animProp,t):"ticker"==e&&r.animate(a,speed,"linear",function(){b(s.resetValue,"reset",0),N()})}},w=function(){for(var e="",i=x(),s=0;i>s;s++){var n="";o.settings.buildPager&&t.isFunction(o.settings.buildPager)?(n=o.settings.buildPager(s),o.pagerEl.addClass("bx-custom-pager")):(n=s+1,o.pagerEl.addClass("bx-default-pager")),e+='<div class="bx-pager-item"><a href="" data-slide-index="'+s+'" class="bx-pager-link">'+n+"</a></div>"}o.pagerEl.html(e)},T=function(){o.settings.pagerCustom?o.pagerEl=t(o.settings.pagerCustom):(o.pagerEl=t('<div class="bx-pager" />'),o.settings.pagerSelector?t(o.settings.pagerSelector).html(o.pagerEl):o.controls.el.addClass("bx-has-pager").append(o.pagerEl),w()),o.pagerEl.on("click","a",I)},C=function(){o.controls.next=t('<a class="bx-next" href="">'+o.settings.nextText+"</a>"),o.controls.prev=t('<a class="bx-prev" href="">'+o.settings.prevText+"</a>"),o.controls.next.bind("click",y),o.controls.prev.bind("click",z),o.settings.nextSelector&&t(o.settings.nextSelector).append(o.controls.next),o.settings.prevSelector&&t(o.settings.prevSelector).append(o.controls.prev),o.settings.nextSelector||o.settings.prevSelector||(o.controls.directionEl=t('<div class="bx-controls-direction" />'),o.controls.directionEl.append(o.controls.prev).append(o.controls.next),o.controls.el.addClass("bx-has-controls-direction").append(o.controls.directionEl))},E=function(){o.controls.start=t('<div class="bx-controls-auto-item"><a class="bx-start" href="">'+o.settings.startText+"</a></div>"),o.controls.stop=t('<div class="bx-controls-auto-item"><a class="bx-stop" href="">'+o.settings.stopText+"</a></div>"),o.controls.autoEl=t('<div class="bx-controls-auto" />'),o.controls.autoEl.on("click",".bx-start",k),o.controls.autoEl.on("click",".bx-stop",M),o.settings.autoControlsCombine?o.controls.autoEl.append(o.controls.start):o.controls.autoEl.append(o.controls.start).append(o.controls.stop),o.settings.autoControlsSelector?t(o.settings.autoControlsSelector).html(o.controls.autoEl):o.controls.el.addClass("bx-has-controls-auto").append(o.controls.autoEl),A(o.settings.autoStart?"stop":"start")},P=function(){o.children.each(function(){var e=t(this).find("img:first").attr("title");void 0!=e&&(""+e).length&&t(this).append('<div class="bx-caption"><span>'+e+"</span></div>")})},y=function(t){o.settings.auto&&r.stopAuto(),r.goToNextSlide(),t.preventDefault()},z=function(t){o.settings.auto&&r.stopAuto(),r.goToPrevSlide(),t.preventDefault()},k=function(t){r.startAuto(),t.preventDefault()},M=function(t){r.stopAuto(),t.preventDefault()},I=function(e){o.settings.auto&&r.stopAuto();var i=t(e.currentTarget),s=parseInt(i.attr("data-slide-index"));s!=o.active.index&&r.goToSlide(s),e.preventDefault()},q=function(e){var i=o.children.length;return"short"==o.settings.pagerType?(o.settings.maxSlides>1&&(i=Math.ceil(o.children.length/o.settings.maxSlides)),o.pagerEl.html(e+1+o.settings.pagerShortSeparator+i),void 0):(o.pagerEl.find("a").removeClass("active"),o.pagerEl.each(function(i,s){t(s).find("a").eq(e).addClass("active")}),void 0)},D=function(){if(o.settings.infiniteLoop){var t="";0==o.active.index?t=o.children.eq(0).position():o.active.index==x()-1&&o.carousel?t=o.children.eq((x()-1)*m()).position():o.active.index==o.children.length-1&&(t=o.children.eq(o.children.length-1).position()),t&&("horizontal"==o.settings.mode?b(-t.left,"reset",0):"vertical"==o.settings.mode&&b(-t.top,"reset",0))}o.working=!1,o.settings.onSlideAfter(o.children.eq(o.active.index),o.oldIndex,o.active.index)},A=function(t){o.settings.autoControlsCombine?o.controls.autoEl.html(o.controls[t]):(o.controls.autoEl.find("a").removeClass("active"),o.controls.autoEl.find("a:not(.bx-"+t+")").addClass("active"))},W=function(){1==x()?(o.controls.prev.addClass("disabled"),o.controls.next.addClass("disabled")):!o.settings.infiniteLoop&&o.settings.hideControlOnEnd&&(0==o.active.index?(o.controls.prev.addClass("disabled"),o.controls.next.removeClass("disabled")):o.active.index==x()-1?(o.controls.next.addClass("disabled"),o.controls.prev.removeClass("disabled")):(o.controls.prev.removeClass("disabled"),o.controls.next.removeClass("disabled")))},H=function(){o.settings.autoDelay>0?setTimeout(r.startAuto,o.settings.autoDelay):r.startAuto(),o.settings.autoHover&&r.hover(function(){o.interval&&(r.stopAuto(!0),o.autoPaused=!0)},function(){o.autoPaused&&(r.startAuto(!0),o.autoPaused=null)})},L=function(){var e=0;if("next"==o.settings.autoDirection)r.append(o.children.clone().addClass("bx-clone"));else{r.prepend(o.children.clone().addClass("bx-clone"));var i=o.children.first().position();e="horizontal"==o.settings.mode?-i.left:-i.top}b(e,"reset",0),o.settings.pager=!1,o.settings.controls=!1,o.settings.autoControls=!1,o.settings.tickerHover&&!o.usingCSS&&o.viewport.hover(function(){r.stop()},function(){var e=0;o.children.each(function(){e+="horizontal"==o.settings.mode?t(this).outerWidth(!0):t(this).outerHeight(!0)});var i=o.settings.speed/e,s="horizontal"==o.settings.mode?"left":"top",n=i*(e-Math.abs(parseInt(r.css(s))));N(n)}),N()},N=function(t){speed=t?t:o.settings.speed;var e={left:0,top:0},i={left:0,top:0};"next"==o.settings.autoDirection?e=r.find(".bx-clone").first().position():i=o.children.first().position();var s="horizontal"==o.settings.mode?-e.left:-e.top,n="horizontal"==o.settings.mode?-i.left:-i.top,a={resetValue:n};b(s,"ticker",speed,a)},O=function(){o.touch={start:{x:0,y:0},end:{x:0,y:0}},o.viewport.bind("touchstart",X)},X=function(t){if(o.working)t.preventDefault();else{o.touch.originalPos=r.position();var e=t.originalEvent;o.touch.start.x=e.changedTouches[0].pageX,o.touch.start.y=e.changedTouches[0].pageY,o.viewport.bind("touchmove",Y),o.viewport.bind("touchend",V)}},Y=function(t){var e=t.originalEvent,i=Math.abs(e.changedTouches[0].pageX-o.touch.start.x),s=Math.abs(e.changedTouches[0].pageY-o.touch.start.y);if(3*i>s&&o.settings.preventDefaultSwipeX?t.preventDefault():3*s>i&&o.settings.preventDefaultSwipeY&&t.preventDefault(),"fade"!=o.settings.mode&&o.settings.oneToOneTouch){var n=0;if("horizontal"==o.settings.mode){var r=e.changedTouches[0].pageX-o.touch.start.x;n=o.touch.originalPos.left+r}else{var r=e.changedTouches[0].pageY-o.touch.start.y;n=o.touch.originalPos.top+r}b(n,"reset",0)}},V=function(t){o.viewport.unbind("touchmove",Y);var e=t.originalEvent,i=0;if(o.touch.end.x=e.changedTouches[0].pageX,o.touch.end.y=e.changedTouches[0].pageY,"fade"==o.settings.mode){var s=Math.abs(o.touch.start.x-o.touch.end.x);s>=o.settings.swipeThreshold&&(o.touch.start.x>o.touch.end.x?r.goToNextSlide():r.goToPrevSlide(),r.stopAuto())}else{var s=0;"horizontal"==o.settings.mode?(s=o.touch.end.x-o.touch.start.x,i=o.touch.originalPos.left):(s=o.touch.end.y-o.touch.start.y,i=o.touch.originalPos.top),!o.settings.infiniteLoop&&(0==o.active.index&&s>0||o.active.last&&0>s)?b(i,"reset",200):Math.abs(s)>=o.settings.swipeThreshold?(0>s?r.goToNextSlide():r.goToPrevSlide(),r.stopAuto()):b(i,"reset",200)}o.viewport.unbind("touchend",V)},Z=function(){var e=t(window).width(),i=t(window).height();(a!=e||l!=i)&&(a=e,l=i,r.redrawSlider(),o.settings.onSliderResize.call(r,o.active.index))};return r.goToSlide=function(e,i){if(!o.working&&o.active.index!=e)if(o.working=!0,o.oldIndex=o.active.index,o.active.index=0>e?x()-1:e>=x()?0:e,o.settings.onSlideBefore(o.children.eq(o.active.index),o.oldIndex,o.active.index),"next"==i?o.settings.onSlideNext(o.children.eq(o.active.index),o.oldIndex,o.active.index):"prev"==i&&o.settings.onSlidePrev(o.children.eq(o.active.index),o.oldIndex,o.active.index),o.active.last=o.active.index>=x()-1,o.settings.pager&&q(o.active.index),o.settings.controls&&W(),"fade"==o.settings.mode)o.settings.adaptiveHeight&&o.viewport.height()!=v()&&o.viewport.animate({height:v()},o.settings.adaptiveHeightSpeed),o.children.filter(":visible").fadeOut(o.settings.speed).css({zIndex:0}),o.children.eq(o.active.index).css("zIndex",o.settings.slideZIndex+1).fadeIn(o.settings.speed,function(){t(this).css("zIndex",o.settings.slideZIndex),D()});else{o.settings.adaptiveHeight&&o.viewport.height()!=v()&&o.viewport.animate({height:v()},o.settings.adaptiveHeightSpeed);var s=0,n={left:0,top:0};if(!o.settings.infiniteLoop&&o.carousel&&o.active.last)if("horizontal"==o.settings.mode){var a=o.children.eq(o.children.length-1);n=a.position(),s=o.viewport.width()-a.outerWidth()}else{var l=o.children.length-o.settings.minSlides;n=o.children.eq(l).position()}else if(o.carousel&&o.active.last&&"prev"==i){var d=1==o.settings.moveSlides?o.settings.maxSlides-m():(x()-1)*m()-(o.children.length-o.settings.maxSlides),a=r.children(".bx-clone").eq(d);n=a.position()}else if("next"==i&&0==o.active.index)n=r.find("> .bx-clone").eq(o.settings.maxSlides).position(),o.active.last=!1;else if(e>=0){var c=e*m();n=o.children.eq(c).position()}if("undefined"!=typeof n){var g="horizontal"==o.settings.mode?-(n.left-s):-n.top;b(g,"slide",o.settings.speed)}}},r.goToNextSlide=function(){if(o.settings.infiniteLoop||!o.active.last){var t=parseInt(o.active.index)+1;r.goToSlide(t,"next")}},r.goToPrevSlide=function(){if(o.settings.infiniteLoop||0!=o.active.index){var t=parseInt(o.active.index)-1;r.goToSlide(t,"prev")}},r.startAuto=function(t){o.interval||(o.interval=setInterval(function(){"next"==o.settings.autoDirection?r.goToNextSlide():r.goToPrevSlide()},o.settings.pause),o.settings.autoControls&&1!=t&&A("stop"))},r.stopAuto=function(t){o.interval&&(clearInterval(o.interval),o.interval=null,o.settings.autoControls&&1!=t&&A("start"))},r.getCurrentSlide=function(){return o.active.index},r.getCurrentSlideElement=function(){return o.children.eq(o.active.index)},r.getSlideCount=function(){return o.children.length},r.redrawSlider=function(){o.children.add(r.find(".bx-clone")).outerWidth(u()),o.viewport.css("height",v()),o.settings.ticker||S(),o.active.last&&(o.active.index=x()-1),o.active.index>=x()&&(o.active.last=!0),o.settings.pager&&!o.settings.pagerCustom&&(w(),q(o.active.index))},r.destroySlider=function(){o.initialized&&(o.initialized=!1,t(".bx-clone",this).remove(),o.children.each(function(){void 0!=t(this).data("origStyle")?t(this).attr("style",t(this).data("origStyle")):t(this).removeAttr("style")}),void 0!=t(this).data("origStyle")?this.attr("style",t(this).data("origStyle")):t(this).removeAttr("style"),t(this).unwrap().unwrap(),o.controls.el&&o.controls.el.remove(),o.controls.next&&o.controls.next.remove(),o.controls.prev&&o.controls.prev.remove(),o.pagerEl&&o.settings.controls&&o.pagerEl.remove(),t(".bx-caption",this).remove(),o.controls.autoEl&&o.controls.autoEl.remove(),clearInterval(o.interval),o.settings.responsive&&t(window).unbind("resize",Z))},r.reloadSlider=function(t){void 0!=t&&(n=t),r.destroySlider(),d()},d(),this}}(jQuery);
|
skin/frontend/base/default/js/srdt/jquery.easing.1.3.js
ADDED
@@ -0,0 +1,205 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/*
|
2 |
+
* jQuery Easing v1.3 - http://gsgd.co.uk/sandbox/jquery/easing/
|
3 |
+
*
|
4 |
+
* Uses the built in easing capabilities added In jQuery 1.1
|
5 |
+
* to offer multiple easing options
|
6 |
+
*
|
7 |
+
* TERMS OF USE - jQuery Easing
|
8 |
+
*
|
9 |
+
* Open source under the BSD License.
|
10 |
+
*
|
11 |
+
* Copyright © 2008 George McGinley Smith
|
12 |
+
* All rights reserved.
|
13 |
+
*
|
14 |
+
* Redistribution and use in source and binary forms, with or without modification,
|
15 |
+
* are permitted provided that the following conditions are met:
|
16 |
+
*
|
17 |
+
* Redistributions of source code must retain the above copyright notice, this list of
|
18 |
+
* conditions and the following disclaimer.
|
19 |
+
* Redistributions in binary form must reproduce the above copyright notice, this list
|
20 |
+
* of conditions and the following disclaimer in the documentation and/or other materials
|
21 |
+
* provided with the distribution.
|
22 |
+
*
|
23 |
+
* Neither the name of the author nor the names of contributors may be used to endorse
|
24 |
+
* or promote products derived from this software without specific prior written permission.
|
25 |
+
*
|
26 |
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
27 |
+
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
28 |
+
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
29 |
+
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
30 |
+
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
31 |
+
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
32 |
+
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
33 |
+
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
34 |
+
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
35 |
+
*
|
36 |
+
*/
|
37 |
+
|
38 |
+
// t: current time, b: begInnIng value, c: change In value, d: duration
|
39 |
+
jQuery.easing['jswing'] = jQuery.easing['swing'];
|
40 |
+
|
41 |
+
jQuery.extend( jQuery.easing,
|
42 |
+
{
|
43 |
+
def: 'easeOutQuad',
|
44 |
+
swing: function (x, t, b, c, d) {
|
45 |
+
//alert(jQuery.easing.default);
|
46 |
+
return jQuery.easing[jQuery.easing.def](x, t, b, c, d);
|
47 |
+
},
|
48 |
+
easeInQuad: function (x, t, b, c, d) {
|
49 |
+
return c*(t/=d)*t + b;
|
50 |
+
},
|
51 |
+
easeOutQuad: function (x, t, b, c, d) {
|
52 |
+
return -c *(t/=d)*(t-2) + b;
|
53 |
+
},
|
54 |
+
easeInOutQuad: function (x, t, b, c, d) {
|
55 |
+
if ((t/=d/2) < 1) return c/2*t*t + b;
|
56 |
+
return -c/2 * ((--t)*(t-2) - 1) + b;
|
57 |
+
},
|
58 |
+
easeInCubic: function (x, t, b, c, d) {
|
59 |
+
return c*(t/=d)*t*t + b;
|
60 |
+
},
|
61 |
+
easeOutCubic: function (x, t, b, c, d) {
|
62 |
+
return c*((t=t/d-1)*t*t + 1) + b;
|
63 |
+
},
|
64 |
+
easeInOutCubic: function (x, t, b, c, d) {
|
65 |
+
if ((t/=d/2) < 1) return c/2*t*t*t + b;
|
66 |
+
return c/2*((t-=2)*t*t + 2) + b;
|
67 |
+
},
|
68 |
+
easeInQuart: function (x, t, b, c, d) {
|
69 |
+
return c*(t/=d)*t*t*t + b;
|
70 |
+
},
|
71 |
+
easeOutQuart: function (x, t, b, c, d) {
|
72 |
+
return -c * ((t=t/d-1)*t*t*t - 1) + b;
|
73 |
+
},
|
74 |
+
easeInOutQuart: function (x, t, b, c, d) {
|
75 |
+
if ((t/=d/2) < 1) return c/2*t*t*t*t + b;
|
76 |
+
return -c/2 * ((t-=2)*t*t*t - 2) + b;
|
77 |
+
},
|
78 |
+
easeInQuint: function (x, t, b, c, d) {
|
79 |
+
return c*(t/=d)*t*t*t*t + b;
|
80 |
+
},
|
81 |
+
easeOutQuint: function (x, t, b, c, d) {
|
82 |
+
return c*((t=t/d-1)*t*t*t*t + 1) + b;
|
83 |
+
},
|
84 |
+
easeInOutQuint: function (x, t, b, c, d) {
|
85 |
+
if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b;
|
86 |
+
return c/2*((t-=2)*t*t*t*t + 2) + b;
|
87 |
+
},
|
88 |
+
easeInSine: function (x, t, b, c, d) {
|
89 |
+
return -c * Math.cos(t/d * (Math.PI/2)) + c + b;
|
90 |
+
},
|
91 |
+
easeOutSine: function (x, t, b, c, d) {
|
92 |
+
return c * Math.sin(t/d * (Math.PI/2)) + b;
|
93 |
+
},
|
94 |
+
easeInOutSine: function (x, t, b, c, d) {
|
95 |
+
return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b;
|
96 |
+
},
|
97 |
+
easeInExpo: function (x, t, b, c, d) {
|
98 |
+
return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b;
|
99 |
+
},
|
100 |
+
easeOutExpo: function (x, t, b, c, d) {
|
101 |
+
return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
|
102 |
+
},
|
103 |
+
easeInOutExpo: function (x, t, b, c, d) {
|
104 |
+
if (t==0) return b;
|
105 |
+
if (t==d) return b+c;
|
106 |
+
if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b;
|
107 |
+
return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;
|
108 |
+
},
|
109 |
+
easeInCirc: function (x, t, b, c, d) {
|
110 |
+
return -c * (Math.sqrt(1 - (t/=d)*t) - 1) + b;
|
111 |
+
},
|
112 |
+
easeOutCirc: function (x, t, b, c, d) {
|
113 |
+
return c * Math.sqrt(1 - (t=t/d-1)*t) + b;
|
114 |
+
},
|
115 |
+
easeInOutCirc: function (x, t, b, c, d) {
|
116 |
+
if ((t/=d/2) < 1) return -c/2 * (Math.sqrt(1 - t*t) - 1) + b;
|
117 |
+
return c/2 * (Math.sqrt(1 - (t-=2)*t) + 1) + b;
|
118 |
+
},
|
119 |
+
easeInElastic: function (x, t, b, c, d) {
|
120 |
+
var s=1.70158;var p=0;var a=c;
|
121 |
+
if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3;
|
122 |
+
if (a < Math.abs(c)) { a=c; var s=p/4; }
|
123 |
+
else var s = p/(2*Math.PI) * Math.asin (c/a);
|
124 |
+
return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
|
125 |
+
},
|
126 |
+
easeOutElastic: function (x, t, b, c, d) {
|
127 |
+
var s=1.70158;var p=0;var a=c;
|
128 |
+
if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3;
|
129 |
+
if (a < Math.abs(c)) { a=c; var s=p/4; }
|
130 |
+
else var s = p/(2*Math.PI) * Math.asin (c/a);
|
131 |
+
return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
|
132 |
+
},
|
133 |
+
easeInOutElastic: function (x, t, b, c, d) {
|
134 |
+
var s=1.70158;var p=0;var a=c;
|
135 |
+
if (t==0) return b; if ((t/=d/2)==2) return b+c; if (!p) p=d*(.3*1.5);
|
136 |
+
if (a < Math.abs(c)) { a=c; var s=p/4; }
|
137 |
+
else var s = p/(2*Math.PI) * Math.asin (c/a);
|
138 |
+
if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
|
139 |
+
return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b;
|
140 |
+
},
|
141 |
+
easeInBack: function (x, t, b, c, d, s) {
|
142 |
+
if (s == undefined) s = 1.70158;
|
143 |
+
return c*(t/=d)*t*((s+1)*t - s) + b;
|
144 |
+
},
|
145 |
+
easeOutBack: function (x, t, b, c, d, s) {
|
146 |
+
if (s == undefined) s = 1.70158;
|
147 |
+
return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
|
148 |
+
},
|
149 |
+
easeInOutBack: function (x, t, b, c, d, s) {
|
150 |
+
if (s == undefined) s = 1.70158;
|
151 |
+
if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;
|
152 |
+
return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
|
153 |
+
},
|
154 |
+
easeInBounce: function (x, t, b, c, d) {
|
155 |
+
return c - jQuery.easing.easeOutBounce (x, d-t, 0, c, d) + b;
|
156 |
+
},
|
157 |
+
easeOutBounce: function (x, t, b, c, d) {
|
158 |
+
if ((t/=d) < (1/2.75)) {
|
159 |
+
return c*(7.5625*t*t) + b;
|
160 |
+
} else if (t < (2/2.75)) {
|
161 |
+
return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
|
162 |
+
} else if (t < (2.5/2.75)) {
|
163 |
+
return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
|
164 |
+
} else {
|
165 |
+
return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
|
166 |
+
}
|
167 |
+
},
|
168 |
+
easeInOutBounce: function (x, t, b, c, d) {
|
169 |
+
if (t < d/2) return jQuery.easing.easeInBounce (x, t*2, 0, c, d) * .5 + b;
|
170 |
+
return jQuery.easing.easeOutBounce (x, t*2-d, 0, c, d) * .5 + c*.5 + b;
|
171 |
+
}
|
172 |
+
});
|
173 |
+
|
174 |
+
/*
|
175 |
+
*
|
176 |
+
* TERMS OF USE - EASING EQUATIONS
|
177 |
+
*
|
178 |
+
* Open source under the BSD License.
|
179 |
+
*
|
180 |
+
* Copyright © 2001 Robert Penner
|
181 |
+
* All rights reserved.
|
182 |
+
*
|
183 |
+
* Redistribution and use in source and binary forms, with or without modification,
|
184 |
+
* are permitted provided that the following conditions are met:
|
185 |
+
*
|
186 |
+
* Redistributions of source code must retain the above copyright notice, this list of
|
187 |
+
* conditions and the following disclaimer.
|
188 |
+
* Redistributions in binary form must reproduce the above copyright notice, this list
|
189 |
+
* of conditions and the following disclaimer in the documentation and/or other materials
|
190 |
+
* provided with the distribution.
|
191 |
+
*
|
192 |
+
* Neither the name of the author nor the names of contributors may be used to endorse
|
193 |
+
* or promote products derived from this software without specific prior written permission.
|
194 |
+
*
|
195 |
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
196 |
+
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
197 |
+
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
198 |
+
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
199 |
+
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
200 |
+
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
201 |
+
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
202 |
+
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
203 |
+
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
204 |
+
*
|
205 |
+
*/
|
skin/frontend/base/default/js/srdt/jquery.fitvids.js
ADDED
@@ -0,0 +1,80 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/*global jQuery */
|
2 |
+
/*jshint multistr:true browser:true */
|
3 |
+
/*!
|
4 |
+
* FitVids 1.0
|
5 |
+
*
|
6 |
+
* Copyright 2011, Chris Coyier - http://css-tricks.com + Dave Rupert - http://daverupert.com
|
7 |
+
* Credit to Thierry Koblentz - http://www.alistapart.com/articles/creating-intrinsic-ratios-for-video/
|
8 |
+
* Released under the WTFPL license - http://sam.zoy.org/wtfpl/
|
9 |
+
*
|
10 |
+
* Date: Thu Sept 01 18:00:00 2011 -0500
|
11 |
+
*/
|
12 |
+
|
13 |
+
(function( $ ){
|
14 |
+
|
15 |
+
"use strict";
|
16 |
+
|
17 |
+
$.fn.fitVids = function( options ) {
|
18 |
+
var settings = {
|
19 |
+
customSelector: null
|
20 |
+
};
|
21 |
+
|
22 |
+
var div = document.createElement('div'),
|
23 |
+
ref = document.getElementsByTagName('base')[0] || document.getElementsByTagName('script')[0];
|
24 |
+
|
25 |
+
div.className = 'fit-vids-style';
|
26 |
+
div.innerHTML = '­<style> \
|
27 |
+
.fluid-width-video-wrapper { \
|
28 |
+
width: 100%; \
|
29 |
+
position: relative; \
|
30 |
+
padding: 0; \
|
31 |
+
} \
|
32 |
+
\
|
33 |
+
.fluid-width-video-wrapper iframe, \
|
34 |
+
.fluid-width-video-wrapper object, \
|
35 |
+
.fluid-width-video-wrapper embed { \
|
36 |
+
position: absolute; \
|
37 |
+
top: 0; \
|
38 |
+
left: 0; \
|
39 |
+
width: 100%; \
|
40 |
+
height: 100%; \
|
41 |
+
} \
|
42 |
+
</style>';
|
43 |
+
|
44 |
+
ref.parentNode.insertBefore(div,ref);
|
45 |
+
|
46 |
+
if ( options ) {
|
47 |
+
$.extend( settings, options );
|
48 |
+
}
|
49 |
+
|
50 |
+
return this.each(function(){
|
51 |
+
var selectors = [
|
52 |
+
"iframe[src*='player.vimeo.com']",
|
53 |
+
"iframe[src*='www.youtube.com']",
|
54 |
+
"iframe[src*='www.kickstarter.com']",
|
55 |
+
"object",
|
56 |
+
"embed"
|
57 |
+
];
|
58 |
+
|
59 |
+
if (settings.customSelector) {
|
60 |
+
selectors.push(settings.customSelector);
|
61 |
+
}
|
62 |
+
|
63 |
+
var $allVideos = $(this).find(selectors.join(','));
|
64 |
+
|
65 |
+
$allVideos.each(function(){
|
66 |
+
var $this = $(this);
|
67 |
+
if (this.tagName.toLowerCase() === 'embed' && $this.parent('object').length || $this.parent('.fluid-width-video-wrapper').length) { return; }
|
68 |
+
var height = ( this.tagName.toLowerCase() === 'object' || ($this.attr('height') && !isNaN(parseInt($this.attr('height'), 10))) ) ? parseInt($this.attr('height'), 10) : $this.height(),
|
69 |
+
width = !isNaN(parseInt($this.attr('width'), 10)) ? parseInt($this.attr('width'), 10) : $this.width(),
|
70 |
+
aspectRatio = height / width;
|
71 |
+
if(!$this.attr('id')){
|
72 |
+
var videoID = 'fitvid' + Math.floor(Math.random()*999999);
|
73 |
+
$this.attr('id', videoID);
|
74 |
+
}
|
75 |
+
$this.wrap('<div class="fluid-width-video-wrapper"></div>').parent('.fluid-width-video-wrapper').css('padding-top', (aspectRatio * 100)+"%");
|
76 |
+
$this.removeAttr('height').removeAttr('width');
|
77 |
+
});
|
78 |
+
});
|
79 |
+
};
|
80 |
+
})( jQuery );
|