PATH:
home
/
letacommog
/
letaweb
/
scripts
/
editor
/* bae module for all editor */ angular.module('base', ['ngLocale','pagemanager.communication','pagemanager.iframe','pagemanager.link','ui-iconpicker']) .value('data', { noIframe: true, name:'base', }) .config(function($logProvider,$controllerProvider) { $logProvider.debugEnabled(true); $controllerProvider.allowGlobals(); }) .service('skinService', ['$q','communication','$window', function($q,communication,$window) { this.getDefaultSkins = function() { return communication.getList('defaultSkins',{},'content'); } }]) //service to work with document stylesheet .service('stylesheetService', ['$q','communication','$window', function($q,communication,$window) { //load specific document stylesheet content this.getStylesheetContents = function(iframe) { StyleSheet.contents = []; var linkedStyleSheets = iframe.document.styleSheets; var j = false; for(var i = 0;i < linkedStyleSheets.length;i++) { if(!linkedStyleSheets[i].href) continue; var href = linkedStyleSheets[i].href; if(href.indexOf('themes') >= 0) { j = i; break; } } if(!j) return; //load themes.css //themes.css contain all skin preset for widget var themes_StyleSheetObj = linkedStyleSheets[j]; StyleSheet.themes = new StyleSheetObj(themes_StyleSheetObj, 'themes'); //load common_skin.css //common_skin.css contain all base style such as color pallete, body background... //common_skin is edited by using design function on builder var common_skinStyleSheetObj = linkedStyleSheets[j + 1]; StyleSheet.common_skin = new StyleSheetObj(common_skinStyleSheetObj, 'common_skin'); //load skin.css //skin.css contain all skin preset has been customized for a widget var skinStyleSheetObj = linkedStyleSheets[j + 2]; StyleSheet.skin = new StyleSheetObj(skinStyleSheetObj, 'skin'); //load style.css var globalStyleSheetObj = linkedStyleSheets[j + 3]; StyleSheet.global = new StyleSheetObj(globalStyleSheetObj, 'style'); StyleSheet.local = StyleSheet.global; //load main.css //main.css is custom css file for user change manually var mainStyleSheetObj = linkedStyleSheets[j + 4]; StyleSheet.main = new StyleSheetObj(mainStyleSheetObj, 'main'); var StyleSheets = window.document.styleSheets; StyleSheet.contents.push(StyleSheet.themes); StyleSheet.contents.push(StyleSheet.common_skin); StyleSheet.contents.push(StyleSheet.skin); StyleSheet.contents.push(StyleSheet.global); StyleSheet.contents.push(StyleSheet.main); var hrefs = ''; for(var i = 0;i < StyleSheet.contents.length;i++) { if(! StyleSheet.contents[i].is_loaded() ) hrefs += StyleSheet.contents[i].getHref() + ';'; } var that = this; return communication.getStylesheetContents(hrefs).then( function(response) { for(var i = 0;i < StyleSheet.contents.length;i++) { if(! StyleSheet.contents[i].is_loaded() ) StyleSheet.contents[i].getResponse(response); } jQuery.event.trigger('stylesheetLoadCompleted'); }); }; // //function to load builder color palette //color palette contain 25 specific color, which is indexed from 0 to 24. // this.loadPalette = function() { var deferred = $q.defer(); if($window.palette) { deferred.resolve(1); return deferred.promise; } $window.palette = Palette.default; if(StyleSheet.common_skin) { deferred.resolve(1); for(var i = 0;i < 5;i++) { for(var j = 0;j < 5;j++) { var index = i * 5 + j; var color = StyleSheet.common_skin.getPropertyValue('.color-' + index, 'color'); var c = color; $window.palette.setColor(color, index); } } return deferred.promise; } else { var that = this; return communication.api( 'loadPalette', {}).then(function(json) { var s = new StyleSheetObj(); s.importStylesheetContent(json); for(var i = 0;i < 5;i++) { for(var j = 0;j < 5;j++) { var index = i * 5 + j; var color = s.getPropertyValue('.color-' + index, 'color'); var c = color; $window.palette.setColor(color, index); } } return true; }); } } }]) .directive('fixHeightElement', function($window) { return { link: function(scope, element) { var resize = function() { var e = angular.element(element); if(e.children().length == 0) { e.css('height', ''); return; } var w = angular.element($window); var window_height = w.height(); var element_top = e.offset().top; var element_height = window_height - element_top; e.css('height', element_height); } resize(); angular.element($window).bind('resize', resize); element.on('$destroy', function(){ angular.element($window).unbind('resize', resize); }) } } }) .service('childService', ['$state','pageEdit','stylesheetService','skinService','$rootScope','$uibModalStack',function($state,pageEdit,stylesheetService,skinService,$rootScope,$uibModalStack) { this.destroy = function() { $uibModalStack.dismissAll(1); }; //load editting site into an iframe this.load = function() { var edit_page = $('iframe#edit_page'); if(edit_page.length == 0) { var src = $('#edit_page_meta').attr('data-src'); edit_page = $('<iframe id="edit_page" name="edit_page"></iframe'); edit_page.attr('src', src); $('#customize_preview').append(edit_page); var that = this; $('#loadingSpinner').show(); //$('#edit_page').block(); edit_page.load(function () { pageEdit._init(window.edit_page); that.loadCompleted(); that.init(); }); } else { pageEdit._init(window.edit_page); this.init(); } }; //function run when iframe loaded. //just call unblockUI to unblock page and load document stylesheets which needed for builder this.loadCompleted = function() { $('#loadingSpinner').hide(); //$('#edit_page').unblock(); return skinService.getDefaultSkins().then(function() { stylesheetService.getStylesheetContents(window.edit_page).then(function(){ stylesheetService.loadPalette().then(function() { $rootScope.child_load_completed = true; if($rootScope.nextState != undefined) { $state.go($rootScope.nextState); } }); } ); }); }; this.init = function() { }; this.afterInit = function() { }; }]) .service("configurationService", function(communication, $rootScope, $state) { this.data=[]; this.init = function() { var that = this; communication.getList('configuration', {}).then(function(json) { that.data = json; $rootScope.configuration_load_completed = true; if($rootScope.nextState != undefined) { $state.go($rootScope.nextState); } }); }; this.get = function(key, default_value) { if (!(this.data[key])) { return default_value; } return this.data[key]; }; this.set = function(key, value) { return this.data[key] = value; } }) .service('handlerService',['childService','data',function(childService,data) { this.init=function() { }; this._attachHandler = function() { }; this._detachHandler = function() { }; this._attachInstallHandler= function() { }; this.loadCompleted = function() { if(!data.noIframe) { $('#edit_page').show(); // this.editor_holder.css('position', ''); childService.load(); } $('#editor_container').addClass('editor_' + data.name); } }]) .factory('destroyFactory',[function() { return { destroy : function() { } } }]) //factory contain all function needed to init current editor .factory('setupFactory',['childService','destroyFactory','$compile','handlerService','$rootScope','$rootElement','$http','data','communication',function(childService,destroyFactory,$compile,handlerService,$rootScope,$rootElement, $http,data,communication) { return { //load loadEditor: function() { var e = $rootElement; var that = this; handlerService.init(); handlerService._attachHandler(); handlerService.loadCompleted(); }, run:function() { $(window).bind('unloadEditor', function() { childService.destroy(); destroyFactory.destroy(); }); return this.loadEditor(); } } }]);
[+]
..
[-] pagemanager.js
[edit]
[-] customize.js
[edit]
[+]
viewer
[-] ecommerce.js
[edit]
[-] pagemanager.iframe.js
[edit]
[+]
popup
[-] pagemanager.modules.js
[edit]
[+]
customize
[+]
blog
[-] settings.js
[edit]
[+]
modules
[-] content.js
[edit]
[-] blog.js
[edit]
[-] base.js
[edit]
[+]
settings
[+]
ecommerce