PATH:
home
/
letacommog
/
letaweb
/
scripts
/
editor
/
modules
define(['module/base'],function(base) { return createModuleDefinition([base], function($window) { this.clone_need_reload=true; this.initializeData = { settings: { effect: 'random', slices: 15, boxCols: 8, boxRows: 4, animSpeed: 500, pauseTime: 3000, startSlide: 0, directionNav: true, controlNav: true, controlNavThumbs: false, pauseOnHover: true, manualAdvance: false }, images: [{src:'/assets/samples/image.png',caption:'Enter caption here',description:'Enter description here',link:''}, {src:'/assets/samples/image.png',caption:'Enter caption here',description:'Enter description here',link:''}, {src:'/assets/samples/image.png',caption:'Enter caption here',description:'Enter description here',link:''}, ] }; this.loadElement = function(el) { var t = jQuery(el); this._loadElement(el); var slider = this.getNivoSlider(); slider.stop(); }; this.getNivoSlider = function() { return this.getElement().children('.nivoSlider').data('nivoslider'); }; this.getVars = function() { var vars = this.getElement().children('.nivoSlider').data('nivo:vars'); return vars; }; this.setVars = function(vars) { this.getElement().children('.nivoSlider').data('nivo:vars',vars); }; this.controller = function($scope,$moduleInstance, $dialog,$file_manager) { $scope.data.settings = $.extend({}, $moduleInstance.initializeData.settings,$scope.data.settings); $scope.data.settings = $scope.data.settings || {}; $scope.data.settings.pauseTime = parseInt($scope.data.settings.pauseTime || 3000); $scope.data.settings.animSpeed = parseInt($scope.data.settings.animSpeed || 500); $scope.onItemChanged = function(index) { var new_item = $scope.data.images[index]; var div = buildItem(new_item); var t = $moduleInstance.getElement(); var slider = t.children('.nivoSlider'); var image = slider.children('img').eq(index); image.attr('src', new_item.src); var captions = t.children('.nivo-html-captions'); var caption = jQuery('.nivo-html-caption', captions).eq(index); caption.html(''); caption.append('<div class="nivo-caption-title">' + new_item.caption+'</div>'); caption.append('<div class="nivo-caption-description">' + new_item.description + '</div>'); }; $scope.deleteImageItem = function($index) { var r = confirm("Delete slide!"); if (!r) { return; } var currentSlide = getVars().currentSlide; if(currentSlide== $index) $moduleInstance.getNivoSlider().gotoSlide($index); var length = $scope.data.images.length; id = $moduleInstance.getPage_id(); var t = $moduleInstance.getElement(); var slider = t.children('.nivoSlider'); var nivo_control = t.children('.nivo-controlNav'); var image2del = slider.children('img').eq($index); var captions = t.children('.nivo-html-captions'); var caption2del = jQuery('.nivo-html-caption', captions).eq($index); var control2del = jQuery('.nivo-control', nivo_control).eq($index); var vars = getVars(); for(var i = $index+1;i < vars.totalSlides;i++) { var image = slider.children('img').eq(i); image.attr('title', '#'+id + '-caption' + (i - 1)); var caption = jQuery('.nivo-html-caption', slider).eq(i); caption.attr('id', id + '-caption' + (i - 1)); var control = jQuery('.nivo-control', nivo_control).eq(i); caption.attr('rel', (i - 1)); } image2del.remove(); caption2del.remove(); control2del.remove(); $scope.data.images.splice($index ,1); vars.totalSlides--; if($index < $scope.editing_index) { ctrl._selectSlide($scope.editing_index-1); } if($index < vars.currentSlide) vars.currentSlide--; setVars(vars); $scope.onChangeSlide(); }; var getVars = function() { return $moduleInstance.getVars(); } var setVars = function(vars) { $moduleInstance.setVars(vars) } $scope.onChangeSlide = function() { $moduleInstance.getNivoSlider().onChangeSlide(); } $scope.onItemAdded = function() { var new_item = $scope.data.images[$scope.data.images.length - 1]; var t = $moduleInstance.getElement(); var slider = t.children('.nivoSlider'); id = $moduleInstance.getPage_id(); var i = $scope.data.images.length - 1; var image = jQuery('<img/>'); image.hide(); image.attr('src', new_item.src); image.attr('title', '#'+id + '-caption' + i); var mainImage = jQuery('.nivo-main-image', slider); mainImage.before(image); var captions = t.children('.nivo-html-captions'); var caption = jQuery('<div></div>'); caption.addClass('nivo-html-caption'); caption.attr('id', id + '-caption' + i); caption.append('<div class="nivo-caption-title">' + new_item.caption+'</div>'); caption.append('<div class="nivo-caption-description">' + new_item.description + '</div>'); captions.append(caption); var nivo_control = t.children('.nivo-controlNav'); var control = jQuery('<a class="nivo-control" rel="' + i + '">' + (i +1) + '</a>'); nivo_control.append(control); var vars = getVars(); vars.totalSlides++; setVars(vars); $scope.onChangeSlide(); }; var ctrl = this; this._selectSlide = function(index) { if($scope.editing_item == index) return false; $scope.editing_item = $scope.data.images[index]; $scope.editing = true; $scope.editing_index = index; } //ctrl._selectSlide(0); $scope.editImageItem = function(index) { var currentSlide = getVars().currentSlide; ctrl._selectSlide(index); }; $scope.editSlideBG = function() { $file_manager.open().result.then(function(images) { if(images.length == 0) return; var image = images[0]; $scope.editing_item.src = image.full_url; var slider = $moduleInstance.getElement().children('.nivoSlider'); var image = slider.children('img').eq($scope.editing_index); console.log(image); image.attr('src', $scope.editing_item.src); var currentSlide = getVars().currentSlide; if(currentSlide == $scope.editing_index) slider.children('img.nivo-main-image').attr('src', $scope.editing_item.src); }); } $scope.changeSlideInfo = function() { var captions = $moduleInstance.getElement().children('.nivo-html-captions'); var caption = jQuery('.nivo-html-caption', captions).eq($scope.editing_index); caption.html(''); caption.append('<div class="nivo-caption-title">' + $scope.editing_item.caption+'</div>'); caption.append('<div class="nivo-caption-description">' + $scope.editing_item.description + '</div>'); var currentSlide = getVars().currentSlide; if(currentSlide == $scope.editing_index) { $moduleInstance.getElement().children('.nivoSlider').children('.nivo-caption').html(caption.contents()); } } $scope.addImageItem = function() { $file_manager.open().result.then(function(images) { if(images.length == 0) return; var image = images[0]; var data = {src:ImageUtil.decodeImageURL(image.full_url),caption:'',description:'',link:'' }; $scope.data.images.push(data); $scope.onItemAdded(); }); } $scope.changeSettings = function() { var t = $moduleInstance.getElement(); var d = t.children('.images').data('nivoslider'); console.log($scope.data.settings); if(d) { jQuery('.images .nivo-caption', t).remove(); jQuery('.images .nivo-controlNav', t).remove(); jQuery('.images .nivo-directionNav',t).remove(); d.changeSettings($scope.data.settings); } jQuery('.nivo-controlNav a', t).trigger('click'); } }; }); });
[+]
..
[-] productlist.js
[edit]
[-] facebookvideo.js
[edit]
[-] newslist.js
[edit]
[-] image.js
[edit]
[-] video.js
[edit]
[-] button.js
[edit]
[-] zone.js
[edit]
[-] text.js
[edit]
[-] newscategory.js
[edit]
[-] googlemap.js
[edit]
[-] base_structure.js
[edit]
[-] contactform.js
[edit]
[-] spacer.js
[edit]
[-] infobox.js
[edit]
[-] html.js
[edit]
[-] testmodule.js
[edit]
[-] facebookcomment.js
[edit]
[-] iframe.js
[edit]
[-] twitterfeed.js
[edit]
[-] recentnews.js
[edit]
[-] audio_player.js
[edit]
[-] slick.js
[edit]
[-] newsdetail.js
[edit]
[-] facebookpost.js
[edit]
[-] pagezone.js
[edit]
[-] panigation.js
[edit]
[-] row.js
[edit]
[-] __custom_module_template.js
[edit]
[-] carousel.js
[edit]
[-] icon.js
[edit]
[-] typedtext.js
[edit]
[-] newscomment.js
[edit]
[-] box.js
[edit]
[-] base_custom.js
[edit]
[-] wordpress.js
[edit]
[-] base.js
[edit]
[-] column.js
[edit]
[-] fancytext.js
[edit]
[-] recentproduct.js
[edit]
[-] statcounter.js
[edit]
[-] tab.js
[edit]
[-] bootstrap_slider.js
[edit]
[-] ihover.js
[edit]
[-] line.js
[edit]
[-] blogger.js
[edit]
[-] slideshow.js
[edit]
[-] title.js
[edit]
[-] facebookpage.js
[edit]
[-] share_buttons.js
[edit]
[-] facebooklike.js
[edit]
[-] infobanner.js
[edit]
[-] rssfeed.js
[edit]
[-] flash.js
[edit]
[-] countdown.js
[edit]
[-] facebooksend.js
[edit]
[-] mailchimp.js
[edit]
[-] infotable.js
[edit]
[-] navbar.js
[edit]
[-] cycleslider.js
[edit]
[-] modal.js
[edit]
[-] embed.js
[edit]
[-] alert.js
[edit]
[-] progress_bar.js
[edit]
[-] accordion.js
[edit]
[-] youtube.js
[edit]
[-] social_buttons.js
[edit]
[-] productcategory.js
[edit]
[-] menu.js
[edit]
[-] pricetable.js
[edit]
[-] productdetail.js
[edit]
[-] gallery.js
[edit]