PATH:
home
/
letacommog
/
letaweb
/
scripts
/
editor
/
modules
define(function() { return function($window, $dialog, $controller,pageEdit_layout,pageEdit_ddManager,$file_manager,$q,communication, pageEdit,pageEdit_event){ this.controller = function($scope, $modalInstance,$moduleInstance) { $scope.data = $moduleInstance.module_data; $scope.data.layout_type = $scope.data.layout_type || 0; $scope.data.skin = $moduleInstance.skin; $scope.subModules = angular.copy($moduleInstance.subModules); $scope.data.animation = $scope.data.animation || $moduleInstance.getElement().hasClass('animated'); $scope.data.animation_loop = $scope.data.animation_loop || $moduleInstance.getElement().hasClass('infinite'); $scope.animation_types = angular.copy(StyleSheet.animation_types); $scope.changeAnimation = function() { $moduleInstance.getElement().removeClass('infinite'); for(var i= 0;i < StyleSheet.animation_types.length;i++) $moduleInstance.getElement().removeClass(StyleSheet.animation_types[i]); if(!$scope.data.animation) $moduleInstance.getElement().removeClass('animated'); else { $moduleInstance.getElement().addClass('animated'); $scope.data.animation_type = $scope.data.animation_type || 'slideInUp'; $moduleInstance.getElement().addClass($scope.data.animation_type); } if($scope.data.animation_loop) $moduleInstance.getElement().addClass('infinite'); } $scope.close = function() { $modalInstance.dismiss('cancel'); } $scope.cancel = function() { $modalInstance.dismiss('cancel'); } $scope.ok = function() { $modalInstance.dismiss('cancel'); } $scope.filterByLayout = function (item) { return item.format == $scope.data.layout_type;; }; $scope.delete = function() { $dialog.confirm({ title:window.t("LBL_DELETE_WIDGET"), message: window.t("LBL_DELETE_WIDGET_MESSAGE"), }).result.then(function() { $modalInstance.dismiss('cancel'); $moduleInstance.delete(); }); } $scope.clone = function() { $moduleInstance.doclone(); } $scope.skinAction = { mainskinEditable : true, subskinEditable: { }, checkSkinEditable : function(skin,skinList) { var skin; for(var i = 0;i < skinList.length;i++) { if(skin == skinList[i].name) skin = skinList[i]; } if(skin != undefined) return skin.html && skin.html.length>0; return false; }, changeSkin : function(skin) { $scope.oldSkin = $scope.data.skin; $scope.skinAction.remove(); $moduleInstance.changeSkin($scope.data.skin); $scope.skinAction.mainskinEditable = $scope.skinAction.checkSkinEditable($scope.data.skin,$scope.skinList); }, changeSubModuleSkin : function(submodule, skin) { $scope.skinAction._changeSubModuleSkin(submodule.selector, skin); $scope.skinAction.subskinEditable[submodule.uniqueName] = $scope.skinAction.checkSkinEditable(skin,submodule.list); }, _changeSubModuleSkin : function(submodule, skin) { $scope.skinAction.removeSubModule(submodule); $moduleInstance.changeSubModuleSkin(submodule, skin); }, createSelectorTag : function(selectors) { var s = selectors.split(','); var rs = $moduleInstance.getIdentifySelector(true); for(var i = 0; i< s.length - 1;i++) { if(s[i][0] == ':') rs += s[i] + ','; else rs += ' ' + s[i] + ','; } if( s[ s.length - 1 ][0] == ':') rs += s[ s.length - 1 ]; else rs += ' ' + s[ s.length - 1 ]; return rs; }, remove : function() { var cls = $moduleInstance.getIdentifySelector(true); StyleSheet.skin.removeStylesById( cls ); }, removeSubModule : function(submodule) { var cls = $moduleInstance.getIdentifySelector(false); cls+= ' ' + submodule; StyleSheet.skin.removeStylesById( cls ); }, editSkin : function() { var skin; for(var i = 0;i < $scope.skinList.length;i++) { if($scope.data.skin == $scope.skinList[i].name) skin = $scope.skinList[i]; } if(skin != undefined) $moduleInstance.openStyleEditor(skin); }, editSubModuleSkin : function(submodule, skin, skinList) { var s; for(var i = 0;i < skinList.length;i++) { if(skin == skinList[i].name) s = skinList[i]; } if(s != undefined) $moduleInstance.openStyleEditor(s,submodule); } } communication.getSkinList($moduleInstance.type).then(function(list) { $scope.skinList = list; if(list.length > 0 && $moduleInstance.is_new_element && $moduleInstance.getSkin() == false) $moduleInstance.changeSkin(list[0].name); $scope.skinAction.mainskinEditable = $scope.skinAction.checkSkinEditable($scope.data.skin,list); }); for(var i in $scope.subModules) { $scope.data.subModules = $scope.data.subModules || {}; if(!$scope.subModules.hasOwnProperty(i)) continue; var type = $scope.subModules[i].type; var uniqueName = $scope.subModules[i].uniqueName; $scope.data.subModules[uniqueName] = $scope.data.subModules[uniqueName] || ''; communication.getIndexedSkinList(type, i).then(function(result) { $scope.subModules[result.index].list = result.list; $scope.skinAction.subskinEditable[uniqueName] = $scope.skinAction.checkSkinEditable($scope.data.subModules[uniqueName],result.list); }) } var element = $moduleInstance.getElement(); $scope.box_style = StyleSheet.getCSSValues(element, true); $scope.box_style.padding = StyleSheet.getMarginValue(element,'padding', true); $scope.box_style.border = StyleSheet.getBorderValue(element, true); $scope.box_style_selector = '#' + $moduleInstance.getPage_id(); $scope.selectBgImage = function() { $file_manager.open().result.then(function(images) { if(images.length == 0) return; var image = images[0]; var src = image.full_url; $scope.box_style.background_image= src; $scope.changeStyle ($scope.box_style_selector,'background-image', 'url('+src+')') }); } $scope.changeBackgroundImage = function() { if($scope.box_style.background_image.length==0) $scope.removeStyle($scope.box_style_selector,'background-image') $scope.changeStyle ($scope.box_style_selector,'background-image', 'url('+$scope.box_style.background_image+')') } $scope.changeStyle = function(selector,type, value) { StyleSheet.global._setCSS(selector,type,value); } $scope.changeNumberStyle = function(selector,type, value) { $scope.changeStyle(selector,type,value.value + value.unit); } $scope.removeStyle = function(selector,type) { StyleSheet.global.removeProperty(selector,type); } }; this.subModules = []; this.delete = function() { return this._delete(); }; this._delete = function() { var element = this.getElement(); var needUnfloatOdd = false; var odds; var prevModule = element.prev(); if(!pageEdit_ddManager.isFloatingModule(t) && pageEdit_ddManager.isFloatingModule(prevModule)) { needUnfloatOdd = true; odds = jQuery(t).prevAll(); } var module_id = this.getPage_id(); pageEdit_layout.remove_module(element); if(needUnfloatOdd) { odds.each(function() { pageEdit_ddManager.unFloatModule(this); }); } pageEdit.deleteModule(element); if(window.top.StyleSheet && window.top.StyleSheet.skin) window.top.StyleSheet.skin.removeStylesById(module_id); if(window.top.StyleSheet && window.top.StyleSheet.local) window.top.StyleSheet.local.removeStylesById(module_id); return true; }; this.openStyleEditor = function(skin,subModule) { subModule=subModule||''; var that = this; return $dialog.open({ templateUrl: getRelativeUrl() + 'api?path=base&action=getHtml&name=modules/extra/skinEditor', size:'sm', backdrop:false, controller: function($scope,$modalInstance, communication, popup) { var createSelectorTag = function(selectors) { var s = selectors.split(','); var rs = []; if(subModule.length) id = that.getIdentifySelector(); else id = that.getIdentifySelector(true); for(var i = 0; i<= s.length - 1;i++) { if(s[i][0] == ':') rs.push(id + ' ' + subModule + s[i]); else rs.push(id + ' ' + subModule + ' ' + s[i]); } return rs.join(); } var getElementId = function(selectors) { var s = selectors.split(','); var rs = []; var id =''; if(subModule.length) id = that.getIdentifySelector(); else id = that.getIdentifySelector(true); for(var i = 0; i<= s.length - 1;i++) { if(s[i][0] == ':') rs.push(id + ' ' + subModule + s[i]); else rs.push(id + ' ' + subModule + ' ' + s[i]); } return rs[0]; } $scope.skin = skin; $scope.htmlElements = skin.html || {}; for(var i = 0;i < $scope.htmlElements.length;i++) { var type = $scope.htmlElements[i].controls.type || 'text'; var selector = $scope.htmlElements[i].controls.selector || ''; var element = getElementId(selector); var name = $scope.htmlElements[i].name; $scope.skin[i]=jQuery(element).css(type); for(var j = 0; j < StyleSheet.csstag.length;j++) { var tag = StyleSheet.csstag[j]; if(tag[0] == type) { index = j; } } if(index == -1) continue; var tag = StyleSheet.csstag[index]; $scope.htmlElements[i].tag_type = tag[1]; switch(tag[1]) { case 'select': $scope.htmlElements[i].values = tag[2]; break; } } $scope.changeColor = function(selector,type, value) { StyleSheet.skin._setCSS(createSelectorTag(selector), type ,value); } $scope.changeNumber= function(selector,type, value) { StyleSheet.skin._setCSS(createSelectorTag(selector), type ,value + 'px'); } $scope.changePercent= function(selector,type, value) { StyleSheet.skin._setCSS(createSelectorTag(selector), type ,value / 100); } $scope.changeSelect= function(selector,type, value) { StyleSheet.skin._setCSS(createSelectorTag(selector), type ,value); } $scope.changePadding= function(selector,type, value) { StyleSheet.skin._setCSS(createSelectorTag(selector), type ,value + 'px'); } $scope.changeMargin= function(selector,type, value) { StyleSheet.skin._setCSS(createSelectorTag(selector), type ,value + 'px'); } $scope.changeBorderRadius= function(selector,type, value) { StyleSheet.skin._setCSS(createSelectorTag(selector), 'border-radius',value + 'px'); } $scope.remove = function() { var cls = that.getIdentifySelector(); StyleSheet.skin.removeStylesById( cls ); }; $scope.t = window.t; } }); }; this.changeSubModuleSkin = function(submodule, skin) { var element = this.getElement(); var submodule_element = jQuery(submodule, element); var c = submodule_element.attr('class'); if(typeof c == 'undefined') return; c = c.replace(' ', ' '); c = jQuery.trim(c); c = c.split(' '); var class2remove = ''; if(c.length > 1) { class2remove = c[c.length - 1]; submodule_element.removeClass(class2remove); } submodule_element.addClass(skin); }; this.removeSubModuleSkin = function(submodule) { var element = this.getElement(); var submodule_element = jQuery(submodule, element); var c = element.attr('class'); if(typeof c == 'undefined') return; c = c.replace(' ', ' '); c = jQuery.trim(c); c = c.split(' '); var class2remove = ''; if(c.length > 1) { class2remove = c[c.length - 1]; element.removeClass(class2remove); } }; this.changeSkin = function(s) { var element = this.getElement(); var oldSkin = this.skin; element.removeClass(oldSkin); this.skin = s; element.addClass(s); }; this.getSkin = function() { return this.skin; }; this.removeSkin = function() { var element = this.getElement(); if(element.length == 0) { this.skin = ''; return; } var oldSkin = this.skin; element.removeClass(oldSkin); this.skin = ''; }; this.getIdentifySelector = function(with_skin) { with_skin = with_skin || false; var id = this.getElement().attr('id'); if(typeof id != 'undefined') { var m = '#' + id; if(with_skin) { var skin = this.getSkin(); if(!skin) return m; return m + '.' + skin; } return m; } if(typeof this.identitySelector != 'undefined') { var m = ''; if(typeof this.parent_module != 'undefined') m = this.parent_module.getIdentifySelector(false) + ' '; m += this.identitySelector; return m; } }; this.getHtml = function() { return iframeService.getHtml(); }; this.unbindEvent = function() { this._unbindEvent(); }; this._unbindEvent = function() { this.unhover(); if(this.dragHandleElement != undefined) { this.dragHandleElement.remove(); delete this.dragHandleElement; } this.getElement().unbind(); }; this._bindEvent = function() { var that = this; var element = this.getElement(); element.unbind(); element.bind('mouseover', function(event) { if($window.module_editing) return; if($window.dragging) return; //event.stopPropagation(); that.hover(); }); element.bind('mouseleave', function(event) { if($window.module_editing) return; if($window.dragging) return; //event.stopPropagation(); that.unhover(); }); element.bind('dblclick', function(event) { if($window.module_editing) return; event.stopPropagation(); if(that.dragHandleElement != undefined) { that.dragHandleElement.remove(); delete that.dragHandleElement; } that.select(); }); }; this.bindEvent = function() { return this._bindEvent(); }; this.isLockedRow = function() { var element = this.getElement(); var row = element.parents("." + pageEdit_layout.row_class); return row.hasClass(pageEdit_layout.row_locked_class); }; this.handleDragEvent = function(event, ui) { this._handleDragEvent(event, ui); }; this._handleDragEvent = function(event, ui) { if(jQuery(ui.helper).hasClass('ww_widget_drag_zone_helper')) { return; } var element = this.getElement(); if(pageEdit_ddManager.isFloatingModule(element)) return; var dropped = pageEdit_ddManager.inDragHandlerRegion(element); if(dropped) { pageEdit_ddManager.handleInnerOver(event, element,ui ); } }; this.isDraggable = function() { return !this.isLockedRow(); }; this._initDrag = function() { var element = this.getElement(); if(!element.hasClass('ww_dragging')) element.addClass('droppable'); }; this.initDrag = function() { this._initDrag(); }; this.moduleInfoButtons= { 'move':true, 'drag':false, 'plus':true, 'moveup':false, 'movedown':false, 'edit':true, 'delete':true, 'clone':true, }; this.createModuleInfo = function() { if(this.moduleInfoBlock != undefined) { this.moduleInfoBlock.remove(); delete this.moduleInfoBlock; } var that = this; var element = this.getElement(); var block = jQuery('<div class="ww_module_info"/>'); var div = jQuery('<div class="btn-group"></div>'); block.append(div); var div_inner = jQuery('<label class="btn btn-primary info_name"></label>'); div_inner.html(this.display_name); if(this.moduleInfoButtons.move) div_inner.addClass('move_btn fa fa-arrows'); else if(this.moduleInfoButtons.drag) div_inner.addClass('move_btn fa fa-arrows'); div.append(div_inner); if(this.moduleInfoButtons.edit) { var edit_button = jQuery('<button class="btn btn-primary fa fa-cog"/>'); div.append(edit_button); edit_button.click(function() { that.select(); }); } if(this.moduleInfoButtons.plus) { var add_button = jQuery('<button class="btn btn-primary fa fa-plus"/>'); div.append(add_button); add_button.click(function() { $dialog.addNewBlock().result.then(function(type) { var direction = type==1?'top':'bottom'; pageEdit_layout.rowHelper_clickEvent(that.getElement(),direction) }); }); } var hide_button = jQuery('<button class="btn btn-primary fa fa-caret-left"/>'); var show_button = jQuery('<button class="btn btn-primary fa fa-caret-right"/>'); div.append(show_button); div.append(hide_button); if(this.moduleInfoButtons.moveup) { var moveup_button = jQuery('<button class="btn btn-primary fa fa-arrow-up"/>'); div.append(moveup_button); moveup_button.click(function() { that.moveUp(); }); } if(this.moduleInfoButtons.movedown) { var movedown_button = jQuery('<button class="btn btn-primary fa fa-arrow-down"/>'); div.append(movedown_button); movedown_button.click(function() { that.moveDown(); }); } if(this.moduleInfoButtons.delete) { var del_button = jQuery('<button class="btn btn-primary fa fa-trash"/>'); div.append(del_button); del_button.click(function() { $dialog.confirm({ title:window.t("LBL_DELETE_WIDGET"), message: window.t("LBL_DELETE_WIDGET_MESSAGE"), }).result.then(function() { that.delete(); }); }); } if(this.moduleInfoButtons.clone) { var clone_button = jQuery('<button class="btn btn-primary fa fa-copy"/>'); div.append(clone_button); clone_button.click(function() { that.doclone(); }); } element.append(block); show_button.click(function() { jQuery(this).nextAll().show(); jQuery(this).hide(); }) hide_button.click(function() { hide_button_click(this); }); var hide_button_click = function(hide_button) { jQuery(hide_button).nextAll().hide(); jQuery(hide_button).prev().show(); jQuery(hide_button).hide(); } hide_button_click(hide_button); if(this.moduleInfoButtons.move) this.createDragHandler(div_inner); else if(this.moduleInfoButtons.drag) block.draggable(); this.moduleInfoBlock = block; this.setModuleInfoPosition(); }; this.setModuleInfoPosition = function() { //this.moduleInfoBlock[0].style.top="0px"; this.moduleInfoBlock[0].style.left=this.getElement().width()/2 - this.moduleInfoBlock.width()/2+"px"; var top = this.getElement().height()/2 - this.moduleInfoBlock.height()/2; this.moduleInfoBlock[0].style.top=top + "px"; } this.doclone = function() { this.clone(); } this.clone = function() { this._clone(); } this._clone = function() { var new_element = this.getElement().clone(); this.getElement().after(new_element); this.copyDataTo(new_element); } this.copyDataTo = function(new_element) { new_element = jQuery(new_element); jQuery('.ww_module_info',new_element).remove(); var id = pageEdit.generateModuleId(); new_element.attr('id',id); this._copyDataTo(new_element); if(this.clone_need_reload) { var moduleInstance = pageEdit.getModule(new_element); if(moduleInstance!=undefined) moduleInstance.loadHtml(); } } this._copyDataTo = function(new_element) { pageEdit_layout.createCloneModule(new_element, this.getElement()); } this._createCloneObject = function(cloned_element) { jQuery('.ww_module_info',cloned_element).remove(); var oldID = new_module.attr('id'); var id = pageEdit.generateModuleId(); new_module.attr('id',id); var source_element = jQuery('#'+oldID); pageEdit_layout.createCloneModule(new_module, source_element); } this.createDragHandler = function(dragHandler) { var element = jQuery(this.getElement()); dragHandler.attr('element_id', this.page_id); var that = this; dragHandler.draggable({ appendTo: "body", scroll:true, cursorAt: { left: 40,top:40 }, helper: function(event) { return '<div class="ww_widget_drag_helper">' + '<span class="ww_widget_drag_helper_image">'+ '<img src="' + window.top.basePath + that.icon_path + '" alt="" />'+ '</span>' + '</div>'; }, start : function(event,ui) { jQuery(ui.helper).attr("type", that.type); ui.helper.moduleInstance = that; that.is_moving = true; pageEdit_ddManager.init(); jQuery(that.getElement()).addClass('ww_dragging'); }, drag : function(event,ui) { pageEdit_ddManager._dragDrag(event, ui); }, stop : function(event,ui) { var moduleInstance = ui.helper.moduleInstance; delete that.is_moving; jQuery(that.getElement()).removeClass('ww_dragging'); //var that = this; pageEdit_ddManager.destroy(); pageEdit_ddManager._drop_inner().then(function(drp) { var element = drp.element; var pos = drp.direction; var dropInfo = drp.dropInfo; var m = moduleInstance.getElement(); var old_row = m.parents().filter('.' + pageEdit_layout.row_class); var inserted = m; jQuery(m).addClass('moving'); that.move(element, pos, m); // jQuery(m).removeClass('moving'); }); } }); }; this._loadAnimation = function() { var element = this.getElement(); element.on('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function() { element.removeClass('animated'); element.removeClass('infinite'); for(var i= 0;i < StyleSheet.animation_types.length;i++) element.removeClass(StyleSheet.animation_types[i]); }); element.on('webkitAnimationIteration mozAnimationIteration MSAnimationIteration oanimationiteration animationiteration', function() { element.removeClass('animated'); element.removeClass('infinite'); for(var i= 0;i < StyleSheet.animation_types.length;i++) element.removeClass(StyleSheet.animation_types[i]); }); }; this.reloadElement = function() { this.element = jQuery("#" + this.page_id); return this.loadElement(this.element); }; this._loadElement = function(element) { this.element = element; this.skin = this.skin || jQuery(element).attr('data-skin') || ''; this.system_id = this.system_id || jQuery(element).attr('rel') || 0; this.page_id = this.page_id || jQuery(element).attr('id'); var dataDiv = jQuery('script[type="text/json"]#'+this.page_id+'_data'); var dataString = dataDiv.html(); if(this.is_new_element) { this.module_data = this.initializeData; } else if(!this.is_clone_element) { var data = {}; try { data = $.parseJSON(unescape(dataString)); data = $.extend({},true,data); } catch(e) { } this.module_data = this.module_data || data; } $(element).removeAttr('rel') dataDiv.remove(); var that = this; this.bindEvent(); this._loadAnimation(); }; this.getElement = function() { return jQuery(this.element); }; this.getType = function() { return this.type; }; this.getis_Float = function() { return jQuery(this.getElement()).hasClass(pageEdit_layout.column_float_left_class) || jQuery(this.getElement()).hasClass(pageEdit_layout.column_float_right_class); }; this.getfloat_Dir = function() { return jQuery(this.getElement()).hasClass(pageEdit_layout.column_float_left_class) ? 'left' : 'right'; }; this.getfloat_size = function() { var cz = 12; for(var i = 1;i <= cz;i++) { if(jQuery(this.getElement()).hasClass(pageEdit_layout.column_class + i)) return i; } return 0; }; this.getPage_id = function() { return this.page_id || jQuery(this.getElement() ).attr('id'); }; this.getSystem_id = function() { return this.system_id || 0; }; this.getData = function() { return this.module_data; }; this._hover = function() { pageEdit_layout.hightlight(this.getElement()); this.createModuleInfo(); }; this.hover = function() { if(this.selected || this.hovered) return; if(window.hover_element != undefined) { //window.hover_element.unhover(); } window.hover_element = this; this._hover(); this.hovered = true; }; this._unhover = function() { pageEdit_layout.unhightlight(this.getElement()); }; this.unhover = function() { var t = this.getElement(); this._unhover(); this.removeDragHandler(); this.removeModuleInfo(); delete this.hovered delete window.hover_element; }; this.removeDragHandler = function() { if(this.dragHandleElement != undefined) { this.dragHandleElement.remove(); delete this.dragHandleElement; } }; this.removeModuleInfo = function() { if(this.moduleInfoBlock != undefined) { this.moduleInfoBlock.remove(); delete this.moduleInfoBlock; } }; this._select = function() { this.removeModuleInfo(); return this.openEditor(); }; this.select = function() { return this._select(); }; this.openEditor = function() { var that = this; var modal = $dialog.open({ windowTemplateUrl:"template/dialog/window.html", template: $('#module_backend_template_' + that.type).html(),//getRelativeUrl() + 'api?path=base&action=getHtml&name=modules/'+ this.type, // size:'sm', backdrop:false, controller: function($scope,$modalInstance) { $window.module_editing = true; that.editing = true; if(that.bases) { for(var i in that.bases) { if(!that.bases.hasOwnProperty(i)) continue; if(that.bases[i].controller != undefined) { try { $controller(that.bases[i].controller, {$scope: $scope,$modalInstance:$modalInstance, $moduleInstance:that}) } catch(e) { console.log(e); } } } } try { $controller(that.controller, {$scope: $scope,$modalInstance:$modalInstance, $moduleInstance:that}) } catch(e) { console.log(e); } } }); modal.result.then(function() { delete $window.module_editing; delete that.editting; },function() { delete $window.module_editing; delete that.editting; }); return modal; }; this.loadElement = function(el) { return this._loadElement(el); }; this.onloadHtmlCompleted= function(){}; this.moduleshasSameScript=[]; this.checkNeedToLoadScript = function() { if(jQuery('.module-' + this.type).length > 1) return true; for(var i = 0;i < this.moduleshasSameScript.length;i++) { if(jQuery('.module-' + this.moduleshasSameScript[i]).length) return true; } return false; } this.loadHtml = function() { var that = this; return this.getModuleTemplate().then(function(template) { that.getElement().html(''); that.getElement().html(template); that.loadElement(that.getElement()); that.onloadHtmlCompleted(); return that.getElement(); }); }; this.insert = function(dropInfo) { var insert_point = dropInfo.node; var pos = dropInfo.direction; var insertPlacement = this.createInsertPlacement(insert_point, pos, dropInfo); this.element = insertPlacement; var that = this; return this.getModuleTemplate(insertPlacement).then(function(template) { insertPlacement.html(template); that.loadElement(insertPlacement); that.onloadHtmlCompleted(); return insertPlacement; }); }; this.createInsertPlacement = function(insert_point, pos, dropInfo) { return this._createInsertPlacement(insert_point, pos, dropInfo); }; this._createInsertPlacement = function(insert_point, pos, dropInfo) { this.previewModule = jQuery('<div/>'); var id = dropInfo.element_identifier; this.is_new_element = true; this.previewModule.attr('id', id); this.previewModule.addClass('module'); this.previewModule.addClass('module-' + this.type); var inserted = this.previewModule; if(pageEdit_layout.isContent(insert_point) ) { var split_module = jQuery(insert_point).parents("." + pageEdit_layout.module_split_class + ":first"); split_module = pageEdit.getModule(split_module); var floating = false; var floatDir = ""; if(dropInfo.shouldFloat && (dropInfo.direction === "left" || dropInfo.direction === "right")) { floating = true; floatDir = dropInfo.direction; } if(split_module) split_module.insertModule(insert_point, pos, inserted, floating, floatDir); } else if(pageEdit_layout.isRow(insert_point) ) this.row_insertBlock(insert_point, pos, inserted); else if(pageEdit_layout.isColumn(insert_point) ) this.column_insertBlock(insert_point, pos, inserted); else if(pageEdit_layout.isZone(insert_point) ) this.zone_insertBlock(insert_point, pos, inserted); else this.module_insertBlock(insert_point, pos, inserted); return this.previewModule; }; this.move = function(insert_point, pos, element) { var needUnfloat = true; var needUnfloatOdd = false; var odds; var oldParent = jQuery(element).parent(); var prevModule = jQuery(element).prev(); if(!pageEdit_ddManager.isFloatingModule(element) && pageEdit_ddManager.isFloatingModule(prevModule)) { needUnfloatOdd = true; odds = jQuery(element).prevAll(); } if(pageEdit_layout.isContent(insert_point) ) { var dropInfo = pageEdit_ddManager.dropInfo; var split_module = jQuery(insert_point).parents("." + pageEdit_layout.module_class + ":first"); split_module = pageEdit.getModule(split_module); var floating = false; var floatDir = ""; if(dropInfo.shouldFloat && (dropInfo.direction === "left" || dropInfo.direction === "right")) { floating = true; floatDir = dropInfo.direction; needUnfloat = false; } if(split_module) split_module.insertModule(insert_point, pos, element, floating, floatDir); } else if(pageEdit_layout.isRow(insert_point) ) this.row_insertBlock(insert_point, pos, element); else if(pageEdit_layout.isColumn(insert_point) ) this.column_insertBlock(insert_point, pos, element); else if(pageEdit_layout.isZone(insert_point) ) this.zone_insertBlock(insert_point, pos, element); else this.module_insertBlock(insert_point, pos, element); if(needUnfloat) if(pageEdit_ddManager.isFloatingModule(element)) { pageEdit_ddManager.unFloatModule(element); } if(needUnfloatOdd) { odds.each(function(index, element) { pageEdit_ddManager.unFloatModule(this); }); } pageEdit_event.fire(pageEdit_event.BLOCK_MOVED,{'block':element,oldParent: oldParent}); }; this.column_insertBlock = function(insert_point, pos, inserted) { if(pos == 'top' || pos == 'bottom') { var block = jQuery(insert_point).children('.block'); if(block.length==0) { block = jQuery('<div class="block"/>'); jQuery(insert_point).append(block); } pos == 'top' && block.prepend(inserted); pos == 'bottom' && block.append(inserted); } else { inserted = pageEdit_layout.wrap_column(inserted); pos == 'left' && jQuery(insert_point).before(inserted); pos == 'right' && jQuery(insert_point).after(inserted); var row = jQuery(insert_point).parent(); pageEdit_event.fire(pageEdit_event.COLUMN_ADDED,{'block':inserted}); } }; this.zone_insertBlock = function(insert_point, pos, inserted) { if(pos == 'top' || pos == 'bottom') { inserted = pageEdit_layout.wrap_zone(inserted); pos == 'top' && jQuery(insert_point).before(inserted); pos == 'bottom' && jQuery(insert_point).after(inserted); var row = inserted.children().children(); pageEdit_event.fire(pageEdit_event.ZONE_ADDED,{'block':inserted}); pageEdit_event.fire(pageEdit_event.ROW_ADDED,{'block':row}); } }; this.module_insertBlock = function(insert_point, pos, inserted) { if(jQuery(insert_point).is(inserted)) return; if(pos == 'top' || pos == 'bottom') { pos == 'top' && jQuery(insert_point).before(inserted); pos == 'bottom' && jQuery(insert_point).after(inserted); } else { inserted = pageEdit_layout.wrap_column(inserted); var column = jQuery(insert_point).parent().parent(); pos == 'left' && column.before(inserted); pos == 'right' && column.after(inserted); var row = column.parent(); pageEdit_event.fire(pageEdit_event.COLUMN_ADDED,{'block':inserted}); } }; this.row_insertBlock = function(insert_point, pos, inserted) { if(pos == 'top' || pos == 'bottom') { inserted = pageEdit_layout.wrap_row(inserted); wrapped = 'row'; pos == 'top' && jQuery(insert_point).before(inserted); pos == 'bottom' && jQuery(insert_point).after(inserted); pageEdit_event.fire(pageEdit_event.ROW_ADDED,{'block':inserted}); } else { inserted = pageEdit_layout.wrap_column(inserted); pos == 'left' && jQuery(insert_point).prepend(inserted); pos == 'right' && jQuery(insert_point).append(inserted); pageEdit_event.fire(pageEdit_event.COLUMN_ADDED,{'block':inserted}); } }; this._getStructure = function() { var s = {}; s.id = this.getPage_id();; s.data_id = this.getSystem_id();; s.class = jQuery(this.getElement()).attr('class'); s.skin = this.getSkin(); if(!s.skin) s.skin = ''; s.style = ''; s.type = this.getType();; s.is_float = this.getis_Float();; s.float_dir = this.getfloat_Dir();; s.float_size = this.getfloat_size();; var data = this.getData(); s.data = data; return s; }; this.getStructure= function() { var s = this._getStructure(); return s; }; this.getModuleTemplate = function(element) { if(typeof this.template != 'undefined') { var template = this.template; if(typeof this.template == 'function') { template = this.template(); } var defered = $q.defer(); if(typeof html == 'string') { defered.resolve(template); } else defered.reject(0); return defered.promise; } else { var d = {}; d.data = this.getData() || this.initializeData; d.type = this.type; d.script = this.checkNeedToLoadScript(); d.page_id = this.page_id || jQuery(this.getElement()).attr('id'); return communication.getModuleHtml(this.type, d); } }; this.is_floatable = true; // this.is_new_module = true; this.templateUrl=''; this.initializeData={}; }; });
[+]
..
[-] 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]