PATH:
home
/
letacommog
/
letaweb
/
scripts
angular.module('ui.config.edit',[]) .directive('configEdit', ['communication','$timeout','$compile', 'configurationService','$dialog',function(communication,$timeout,$compile,configurationService, $dialog) { return { controller: function configEditCtrl($scope) { $scope.configurations = $scope.configurations || {}; $scope.modules = {}; this.saveConfigs = function() { return communication.api('updateConfigurations', {data:$scope.configurations}); } this.compile = function(element) { $compile(element)($scope); } this.addModuleConfig = function(moduleId,moduleKey, value,lastElement) { if(!value) { moduleData = configurationService.get(moduleId); if(moduleData != undefined) { value = moduleData[moduleKey]; } } if(!$scope.configurations[moduleId]) $scope.configurations[moduleId] = angular.copy(configurationService.get(moduleId)); $scope.configurations[moduleId] = $scope.configurations[moduleId] || {}; $scope.configurations[moduleId][moduleKey] = value; $scope.modules[moduleId] = true; if(lastElement) { var keys = []; for(var i in $scope.configurations) { if($scope.configurations[i] == undefined) continue; keys.push(i); } } } this.addConfig = function(key,lastElement) { $scope.configurations[key] = configurationService.get(key, ""); if(lastElement) { var keys = []; for(var i in $scope.configurations) { if($scope.configurations[i] == undefined || $scope.modules[i] == true) continue; keys.push(i); } if(keys.length) { for(var i = 0;i < keys.length;i++) { $scope.configurations[keys[i]] = configurationService.get(keys[i]); } } } //console.log(configurationService.data); } }, compile: function() { return { post: function(scope, formElement, attr, controller) { var keys = []; for(var i in scope.configurations) { if(scope.configurations[i] == undefined || scope.modules[i] == true) continue; keys.push(i); } }, pre: function(scope, formElement, attr, controller) { if (!attr.action) { // we can't use jq events because if a form is destroyed during submission the default // action is not prevented. see #1238 // // IE 9 is not affected because it doesn't fire a submit event and try to do a full // page reload if the form was destroyed by submission of the form via a click handler // on a button in the form. Looks like an IE9 specific bug. var preventDefaultListener = function(event) { event.preventDefault ? event.preventDefault() : event.returnValue = false; // IE }; $(formElement).bind( 'submit.saveConfig', function(event) { controller.saveConfigs().then(function() { if (angular.isDefined(attr.afterSubmit)) { scope.$eval(attr.afterSubmit); } alert(window.t("LBL_SAVE_SUCCESSFUL")); }); }); } } }; } }; }]) .directive('configEditModuleControl', ['$compile','communication', function($compile,communication) { return { require: '^configEdit', terminal: true, //this setting is important, see explanation below priority: 1000, //this setting is important, see explanation below compile: function compile(element, attrs) { var key = attrs.configEditModuleControl; var splitString = key.split('.'); var moduleId = splitString[0]; var moduleKey = splitString[1]; var lastElement = angular.isDefined(attrs.lastElement); $(element).attr('ng-model', 'configurations.' + key); $(element).removeAttr("config-edit-module-control"); var fn = $compile(element); return { post: function(scope, iElement, attrs, configEditCtrl){ $compile(iElement)(scope); }, pre: function(scope, iElement, attrs, configEditCtrl){ configEditCtrl.addModuleConfig(moduleId,moduleKey, attrs.value, lastElement); } } } } }]) .directive('configEditControl', ['$compile','communication', function($compile,communication) { return { require: '^configEdit', terminal: true, //this setting is important, see explanation below priority: 1000, //this setting is important, see explanation below compile: function compile(element, attrs) { var key = attrs.configEditControl; var lastElement = angular.isDefined(attrs.lastElement); $(element).attr('ng-model', 'configurations.' + key); $(element).removeAttr("config-edit-control"); var fn = $compile(element); return { post: function(scope, iElement, attrs, configEditCtrl){ $compile(iElement)(scope); }, pre: function(scope, iElement, attrs, configEditCtrl){ configEditCtrl.addConfig(key,lastElement); } } } } }]); angular.module("template/tabs/uiTabedit.html", []) .run(["$templateCache", function($templateCache) { $templateCache.put("template/tabs/uiTabedit.html", "<tr ng-class=\"{active: active, disabled: disabled}\">\n" + "<td>\n" + " <a href ng-click=\"select()\" ui-tab-edit-heading-transclude>{{heading}}</a>\n" + " <button class=\"btn btn-small font-trash\" ng-click=\"delete()\"></button>\n" + "</td>\n" + "</tr>\n" + ""); }]); angular.module("template/tabs/uiTabeditset.html", []) .run(["$templateCache", function($templateCache) { $templateCache.put("template/tabs/uiTabeditset.html", "<table class=\"ui_tab_editing table\" ng-hide=\"tabs.length==0\">\n" + "<tr>\n" + "<td class=\"leftElement\">\n" + " <table class=\"table\" ng-transclude></table>\n" + "</td>\n" + "<td class=\"rightElement\" >\n" + " <form name=\"form\" class=\"tab-content\">\n" + " <div class=\"tab-pane\" \n" + " ng-repeat=\"tab in tabs\" \n" + " ng-class=\"{active: tab.active}\"\n" + " ui-tab-edit-transclude=\"tab\"\n" + " ui-tab-dynamic-edit-transclude=\"tab\">\n" + " </div>\n" + " </form>\n" + "<td>\n" + "</tr>\n" + "</table>\n" + ""); }]); angular.module("template/tabs/uiTabEditing.html", []) .run(["$templateCache", function($templateCache) { $templateCache.put("template/tabs/uiTabEditing.html", "<div>\n" + " <ui-tabeditset>\n" + " <ui-tabedit " + " data=\"item\"" + " heading=\"{{item.name}}\"" + " template-url=\"{{templateUrl || templateUrlFunc()(item) }}\"" + " dynamic-ctrl=\"{{dynamicCtrl|| dynamicCtrlFunc()(item) }}\"" + " ng-repeat=\"item in list\" ng-init=\"item.$$index=$index\">" + " </ui-tabedit>\n" + " </ui-tabeditset>\n" + "</div>\n" + ""); }]); angular.module('ui.tab_edit',['stgrid','template/tabs/uiTabeditset.html','template/tabs/uiTabEditing.html','template/tabs/uiTabedit.html']) .service('uiTabEditing_helper', [ function() { this.mapProperty = function(source, dest, id) { for(var i = 0;i < dest.length;i++) { if(angular.isUndefined(dest[i][id])) { if(angular.isDefined(source[i])) { dest[i][id] = source[i][id]; } } } } }]) .directive('uiTabEditing', function(communication) { return { replace:true, require: '^?uiTabForm', scope: { uiTabEditing: '=', saved: '=?saved', templateUrl:'@', dynamicCtrl:'@', templateUrlFunc:'&?', dynamicCtrlFunc:'&?', dynamic:'=?', name:'@', path:'@' }, controller: function($scope) { $scope.triggerChange = true; if($scope.dynamic) { if(angular.isUndefined($scope.templateUrl)) { } } if($scope.dynamic && angular.isDefined($scope.name)) { communication.getList($scope.name, {},$scope.path).then( function(json) { if(json.length > 0) { $scope.triggerChange = false; $scope.uiTabEditing = json; } }); } else { $scope.triggerChange = false; $scope.list = $scope.uiTabEditing || []; } this.delete = function(index) { $scope.list.splice(index, 1); } }, compile: function(elm, attrs, transclude) { return function postLink(scope, elm, attrs, uiTabPaneCtrl) { //console.log(scope); scope.uiTabPaneCtrl = uiTabPaneCtrl; scope.$watch('uiTabEditing', function(n) { scope.list = scope.uiTabEditing; }); scope.$watch('saved', function(n) { if(n) if(uiTabPaneCtrl != undefined) uiTabPaneCtrl.unchanged(); }); scope.$watch('list', function(n,o) { if(!scope.triggerChange) { scope.triggerChange = true; return; } if(n == undefined) return; if(o == undefined) return; if(n.length == 0 && o.length == 0) return; scope.saved = false; if(uiTabPaneCtrl != undefined) uiTabPaneCtrl.changed(); },true); } }, templateUrl:'template/tabs/uiTabEditing.html', }; }) .directive('uiTabeditset', function() { return { restrict: 'E', transclude: true, replace: true, require:'^uiTabEditing', templateUrl: 'template/tabs/uiTabeditset.html', controller: function($scope) { var ctrl = this, tabs = ctrl.tabs = $scope.tabs = []; //$scope.hide = $scope.tabs.length==0; ctrl.select = function(selectedTab) { //console.log('Selecting:' + selectedTab.heading); if(angular.isDefined($scope.form) && !$scope.form.$valid) return false; angular.forEach(tabs, function(tab) { if (tab.active && tab !== selectedTab) { tab.active = false; tab.onDeselect(); } }); if (selectedTab.load !== undefined) { selectedTab.load(); } selectedTab.active = true; selectedTab.onSelect(); }; // console.log($scope); ctrl.addTab = function addTab(tab) { tabs.push(tab); // we can't run the select function on the first tab // since that would select it twice if (tabs.length === 1) { tab.active = true; } else if (tab.active) { //console.log('Selecting2:' + tab.heading); ctrl.select(tab); } }; ctrl.removeTab = function removeTab(tab) { var index = $scope.tabs.indexOf(tab); //Select a new tab if the tab to be removed is selected and not destroyed if (tab.active && tabs.length > 1 && !destroyed) { //If this is the last tab, select the previous tab. else, the next tab. var newActiveIndex = index == tabs.length - 1 ? index - 1 : index + 1; ctrl.select($scope.tabs[newActiveIndex]); } $scope.tabs.splice(index, 1); $scope.uiTabEditingCtrl.delete(index); }; var destroyed; $scope.$on('$destroy', function() { destroyed = true; }); }, compile: function(elm, attrs, transclude) { return function postLink(scope, elm, attrs, uiTabEditingCtrl) { scope.uiTabEditingCtrl = uiTabEditingCtrl; // console.log(uiTabEditingCtrl); } }, scope: { type: '@' }, } }) .directive('uiTabedit', ['communication','$controller','$compile',function(communication,$controller,$compile) { return { require: '^uiTabeditset', transclude: true, restrict: 'E', templateUrl: 'template/tabs/uiTabedit.html', replace: true, scope: { data: '=', active: '=?', heading: '@', onSelect: '&select', //This callback is called in contentHeadingTransclude //once it inserts the tab's content into the dom onDeselect: '&deselect' }, controller: function($scope) { }, compile: function(elm, attrs, transclude) { return function postLink(scope, elm, attrs, uiTabsetCtrl) { scope.$watch('active', function(active) { if (active) { // console.log('Activing:' + scope.heading); if(uiTabsetCtrl.select(scope) === false) scope.active = false; } }); scope.disabled = false; if ( attrs.disabled ) { scope.$parent.$watch($parse(attrs.disabled), function(value) { scope.disabled = !! value; }); } scope.delete = function() { scope.$destroy(); } scope.select = function() { if ( !scope.disabled ) { scope.active = true; } }; var templateCtrl, templateScope; //console.log((attrs.templateUrl) ); //console.log(angular.isDefined(attrs.templateUrl) && angular.isDefined(attrs.controller)); if (angular.isDefined(attrs.templateUrl) && (angular.isDefined(attrs.controller) || angular.isDefined(attrs.dynamicCtrl))) { scope._compile = function() { var createElement = function(f) { try { templateScope = scope.$new(); templateScope.isTabbedPane = true; if(f != undefined) templateCtrl = $controller(f, {$scope: templateScope}); else templateCtrl = $controller(attrs.controller, {$scope: templateScope}); $compile(scope.contentElement)(templateScope); scope.$apply(); scope.loaded = true; } catch(e) { console.log(e); } } if(angular.isDefined(attrs.dynamicCtrl) ) { require([attrs.dynamicCtrl], function(f) { createElement(f); }); } else createElement(); } scope.load = function() { if(!scope.loaded) communication.getHtml(attrs.templateUrl).then(function(response) { var element = angular.element(response); scope.contentElement = element; }); }; } uiTabsetCtrl.addTab(scope); scope.$on('$destroy', function() { //console.log('Remove tab: ' + scope.heading); uiTabsetCtrl.removeTab(scope); }); //We need to transclude later, once the content container is ready. //when this link happens, we're inside a tab heading. scope.$transcludeFn = transclude; }; } } }]) .directive('uiTabEditHeadingTransclude', [function() { return { restrict: 'A', require: '^uiTabedit', link: function(scope, elm, attrs, tabCtrl) { scope.$watch('headingElement', function updateHeadingElement(heading) { if (heading) { elm.html(''); elm.append(heading); } }); } }; }]) .directive('uiTabDynamicEditTransclude', function() { return { restrict: 'A', require: '^uiTabeditset', link: function(scope, elm, attrs) { var tab = scope.$eval(attrs.uiTabDynamicEditTransclude); tab.$watch('contentElement', function updateContentlement(content) { if (content) { elm.html(''); elm.append(content); tab._compile(); } }); } }; }) .directive('uiTabEditTransclude', function() { return { restrict: 'A', require: '^uiTabeditset', link: function(scope, elm, attrs) { var tab = scope.$eval(attrs.uiTabEditTransclude); //Now our tab is ready to be transcluded: both the tab heading area //and the tab content area are loaded. Transclude 'em both. tab.$transcludeFn(tab.$parent, function(contents) { angular.forEach(contents, function(node) { if (isTabHeading(node)) { //Let tabHeadingTransclude know. tab.headingElement = node; } else { elm.append(node); } }); }); } }; function isTabHeading(node) { return node.tagName && ( node.hasAttribute('tab-heading') || node.hasAttribute('data-tab-heading') || node.tagName.toLowerCase() === 'tab-heading' || node.tagName.toLowerCase() === 'data-tab-heading' ); } }) .directive('uiTabeditRelatedGrid', [function() { return { scope: { } }; }]); ;
[+]
..
[+]
sample_images
[-] ssultils.js
[edit]
[-] dialog.js
[edit]
[-] colorpicker.js
[edit]
[-] script.js
[edit]
[+]
libraries
[-] ui.dbfilter-editing.js
[edit]
[-] stgrid.js
[edit]
[-] ui.category-editing.js
[edit]
[-] forms.js
[edit]
[-] player.swf
[edit]
[-] language.js
[edit]
[-] im.js
[edit]
[-] terms_en.js
[edit]
[-] skinutils.js
[edit]
[-] create_page.js
[edit]
[-] ihover.js
[edit]
[-] builder.js
[edit]
[-] ui.tab-content.js
[edit]
[-] admin.js
[edit]
[-] ui.tab-editing.js
[edit]
[-] login.js
[edit]
[-] popup.js
[edit]
[-] ecommerce.js
[edit]
[-] stEditor.js
[edit]
[-] colorutils.js
[edit]
[-] livedemo.js
[edit]
[-] palette.js
[edit]
[+]
editor