|
|
@@ -1,128 +1,128 @@
|
|
|
-define(['angular'], function(angular) {
|
|
|
- 'use strict';
|
|
|
- angular.module('common.directives', []).directive('scrollTable', [function(){
|
|
|
- // table 固定表头
|
|
|
- return {
|
|
|
- restrict : 'A',
|
|
|
- link : function(scope, element, attrs, ngModel) {
|
|
|
- var header = element.find('.table-header-wrap'), body = element.find('.table-body-wrap');
|
|
|
- if(header && body) {
|
|
|
- body.bind('scroll', function() {
|
|
|
- header.scrollLeft(body.scrollLeft());
|
|
|
- });
|
|
|
- }
|
|
|
- }
|
|
|
- };
|
|
|
- }])
|
|
|
- .directive("slideFollow",function($timeout){
|
|
|
- return {
|
|
|
- restrict : 'E',
|
|
|
- replace : true,
|
|
|
- scope : {
|
|
|
- id : "@",
|
|
|
- datasetData : "="
|
|
|
- },
|
|
|
- template : "<span ng-repeat = 'data in datasetData'><img src='static/img/all/circle.png' class='circle'/>{{data.option}}<img src='static/img/home/new.png' class='new'/></span>",
|
|
|
- link : function(scope, elem, attrs) {
|
|
|
- $timeout(function(){
|
|
|
- var className = $("." + $(elem).parent()[0].className);
|
|
|
- console.log(className);
|
|
|
- var i = 0, sh;
|
|
|
- var liLength = className.children("span").length;
|
|
|
- var liWidth = className.children("span").width() + parseInt(className.children("span").css('border-bottom-width'));
|
|
|
- className.html(className.html() + className.html());
|
|
|
- // 开启定时器
|
|
|
- sh = setInterval(slide, 500);
|
|
|
- function slide(){
|
|
|
- if (parseInt(className.css("margin-left")) > (-liLength * liWidth)) {
|
|
|
- console.log('1' +className.css("margin-left"));
|
|
|
- console.log(-liLength * liWidth)
|
|
|
- i++;
|
|
|
- className.animate({
|
|
|
- marginLeft : -liWidth * i + "px"
|
|
|
- }, 1000);
|
|
|
- } else {
|
|
|
- i = 0;
|
|
|
- className.css("margin-left", "0px");
|
|
|
- }
|
|
|
- }
|
|
|
+define(['angular'], function (angular) {
|
|
|
+ 'use strict';
|
|
|
+ angular.module('common.directives', []).directive('scrollTable', [function () {
|
|
|
+ // table 固定表头
|
|
|
+ return {
|
|
|
+ restrict: 'A',
|
|
|
+ link: function (scope, element, attrs, ngModel) {
|
|
|
+ var header = element.find('.table-header-wrap'), body = element.find('.table-body-wrap');
|
|
|
+ if (header && body) {
|
|
|
+ body.bind('scroll', function () {
|
|
|
+ header.scrollLeft(body.scrollLeft());
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+ }])
|
|
|
+ .directive("slideFollow", function ($timeout) {
|
|
|
+ return {
|
|
|
+ restrict: 'E',
|
|
|
+ replace: true,
|
|
|
+ scope: {
|
|
|
+ id: "@",
|
|
|
+ datasetData: "="
|
|
|
+ },
|
|
|
+ template: "<span ng-repeat = 'data in datasetData'><img src='static/img/all/circle.png' class='circle'/>{{data.option}}<img src='static/img/home/new.png' class='new'/></span>",
|
|
|
+ link: function (scope, elem, attrs) {
|
|
|
+ $timeout(function () {
|
|
|
+ var className = $("." + $(elem).parent()[0].className);
|
|
|
+ console.log(className);
|
|
|
+ var i = 0, sh;
|
|
|
+ var liLength = className.children("span").length;
|
|
|
+ var liWidth = className.children("span").width() + parseInt(className.children("span").css('border-bottom-width'));
|
|
|
+ className.html(className.html() + className.html());
|
|
|
+ // 开启定时器
|
|
|
+ sh = setInterval(slide, 500);
|
|
|
+ function slide() {
|
|
|
+ if (parseInt(className.css("margin-left")) > (-liLength * liWidth)) {
|
|
|
+ console.log('1' + className.css("margin-left"));
|
|
|
+ console.log(-liLength * liWidth)
|
|
|
+ i++;
|
|
|
+ className.animate({
|
|
|
+ marginLeft: -liWidth * i + "px"
|
|
|
+ }, 1000);
|
|
|
+ } else {
|
|
|
+ i = 0;
|
|
|
+ className.css("margin-left", "0px");
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- // 清除定时器
|
|
|
- className.hover(function(){
|
|
|
- clearInterval(sh);
|
|
|
- },function(){
|
|
|
- clearInterval(sh);
|
|
|
- sh = setInterval(slide,1000);
|
|
|
- })
|
|
|
- },0)
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
- /**
|
|
|
- * uiTour directive
|
|
|
- *
|
|
|
- * @example:
|
|
|
- * <ul ui-tour="currentStep">
|
|
|
- * <li target="#someId">
|
|
|
- * First Tooltip
|
|
|
- * <a ng-click="currentStep=currentStep+1">Next</a>
|
|
|
- * </li>
|
|
|
- * <li target=".items:eq(2)" name="two">
|
|
|
- * Second Tooltip
|
|
|
- * <a ng-click="currentStep=currentStep-1">Prev</a>
|
|
|
- * </li>
|
|
|
- * <li target=".items:eq(2)">
|
|
|
- * Third Tooltip
|
|
|
- * <a ng-click="currentStep='two'">Go directly to 'two'</a>
|
|
|
- * <a ng-click="currentStep=0">Done</a>
|
|
|
- * </li>
|
|
|
- * </ul>
|
|
|
- */
|
|
|
- angular.module('ui.tour', [])
|
|
|
-
|
|
|
- .directive('uiTour', ['$timeout', '$parse', function($timeout, $parse){
|
|
|
- return {
|
|
|
- link: function($scope, $element, $attributes) {
|
|
|
- var model = $parse($attributes.uiTour);
|
|
|
-
|
|
|
- // Watch model and change steps
|
|
|
- $scope.$watch($attributes.uiTour, function(newVal, oldVal){
|
|
|
- if (angular.isNumber(newVal)) {
|
|
|
- showStep(newVal)
|
|
|
- } else {
|
|
|
- if (angular.isString(newVal)) {
|
|
|
- var stepNumber = 0,
|
|
|
- children = $element.children()
|
|
|
- angular.forEach(children, function(step, index) {
|
|
|
- if (angular.element(step).attr('name') === newVal)
|
|
|
- stepNumber = index+1;
|
|
|
- });
|
|
|
- model.assign($scope, stepNumber);
|
|
|
- } else {
|
|
|
- model.assign($scope, newVal && 1 || 0);
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- // Show step
|
|
|
- function showStep(stepNumber) {
|
|
|
- var elm, at, children = $element.children().removeClass('active');
|
|
|
- elm = children.eq(stepNumber - 1);
|
|
|
- if (stepNumber) {
|
|
|
- at = elm.attr('at');
|
|
|
- $timeout(function(){
|
|
|
- var target = angular.element(elm.attr('target'))[0];
|
|
|
- if (elm.attr('overlay') !== undefined) {
|
|
|
- $('.tour-overlay').addClass('active').css({}).addClass('in');
|
|
|
- }
|
|
|
- elm.addClass('active');
|
|
|
- });
|
|
|
- } else {
|
|
|
- $('.tour-overlay').removeClass('in');
|
|
|
- $('.tour-overlay').removeClass('active');
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- };
|
|
|
- }]);
|
|
|
+ // 清除定时器
|
|
|
+ className.hover(function () {
|
|
|
+ clearInterval(sh);
|
|
|
+ }, function () {
|
|
|
+ clearInterval(sh);
|
|
|
+ sh = setInterval(slide, 1000);
|
|
|
+ })
|
|
|
+ }, 0)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ /**
|
|
|
+ * uiTour directive
|
|
|
+ *
|
|
|
+ * @example:
|
|
|
+ * <ul ui-tour="currentStep">
|
|
|
+ * <li target="#someId">
|
|
|
+ * First Tooltip
|
|
|
+ * <a ng-click="currentStep=currentStep+1">Next</a>
|
|
|
+ * </li>
|
|
|
+ * <li target=".items:eq(2)" name="two">
|
|
|
+ * Second Tooltip
|
|
|
+ * <a ng-click="currentStep=currentStep-1">Prev</a>
|
|
|
+ * </li>
|
|
|
+ * <li target=".items:eq(2)">
|
|
|
+ * Third Tooltip
|
|
|
+ * <a ng-click="currentStep='two'">Go directly to 'two'</a>
|
|
|
+ * <a ng-click="currentStep=0">Done</a>
|
|
|
+ * </li>
|
|
|
+ * </ul>
|
|
|
+ */
|
|
|
+ // angular.module('ui.tour', [])
|
|
|
+ //
|
|
|
+ // .directive('uiTour', ['$timeout', '$parse', function ($timeout, $parse) {
|
|
|
+ // return {
|
|
|
+ // link: function ($scope, $element, $attributes) {
|
|
|
+ // var model = $parse($attributes.uiTour);
|
|
|
+ //
|
|
|
+ // // Watch model and change steps
|
|
|
+ // $scope.$watch($attributes.uiTour, function (newVal, oldVal) {
|
|
|
+ // if (angular.isNumber(newVal)) {
|
|
|
+ // showStep(newVal)
|
|
|
+ // } else {
|
|
|
+ // if (angular.isString(newVal)) {
|
|
|
+ // var stepNumber = 0,
|
|
|
+ // children = $element.children()
|
|
|
+ // angular.forEach(children, function (step, index) {
|
|
|
+ // if (angular.element(step).attr('name') === newVal)
|
|
|
+ // stepNumber = index + 1;
|
|
|
+ // });
|
|
|
+ // model.assign($scope, stepNumber);
|
|
|
+ // } else {
|
|
|
+ // model.assign($scope, newVal && 1 || 0);
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // });
|
|
|
+ //
|
|
|
+ // // Show step
|
|
|
+ // function showStep(stepNumber) {
|
|
|
+ // var elm, at, children = $element.children().removeClass('active');
|
|
|
+ // elm = children.eq(stepNumber - 1);
|
|
|
+ // if (stepNumber) {
|
|
|
+ // at = elm.attr('at');
|
|
|
+ // $timeout(function () {
|
|
|
+ // var target = angular.element(elm.attr('target'))[0];
|
|
|
+ // if (elm.attr('overlay') !== undefined) {
|
|
|
+ // $('.tour-overlay').addClass('active').css({}).addClass('in');
|
|
|
+ // }
|
|
|
+ // elm.addClass('active');
|
|
|
+ // });
|
|
|
+ // } else {
|
|
|
+ // $('.tour-overlay').removeClass('in');
|
|
|
+ // $('.tour-overlay').removeClass('active');
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // };
|
|
|
+ // }]);
|
|
|
});
|