<apex:component > 
 | 
<script> 
 | 
; 
 | 
'use strict'; 
 | 
angular.module("alDirective", []) 
 | 
// INPUT タグ 用 ディレクティブ 単一ファイル選択 or カメラ 
 | 
.directive("fileModel", ["$parse", function ($parse) { 
 | 
    return { 
 | 
        restrict: "A", 
 | 
        link: function (scope, element, attrs) { 
 | 
            var model = $parse(attrs.fileModel); 
 | 
            element.bind("change", function () { 
 | 
                scope.$apply(function () { 
 | 
                    console.log("input file "); 
 | 
                    model.assign(scope, element[0].files[0]); 
 | 
                }); 
 | 
            }); 
 | 
        } 
 | 
    }; 
 | 
}]) 
 | 
// NPUT タグ 用 ディレクティブ 複数ファイル選択 
 | 
.directive("multifileModel", ["$parse", function ($parse) { 
 | 
    return { 
 | 
        restrict: "A", 
 | 
        link: function (scope, element, attrs) { 
 | 
            var model = $parse(attrs.multifileModel); 
 | 
            element.bind("change", function () { 
 | 
                scope.$apply(function () { 
 | 
                    console.log("input file "); 
 | 
                    model.assign(scope, element[0].files); 
 | 
                }); 
 | 
            }); 
 | 
        } 
 | 
    }; 
 | 
}]) 
 | 
// ロングタップを拾う用 
 | 
// https://gist.github.com/BobNisco/9885852 
 | 
.directive('onLongPress', ['$timeout', '$parse', function($timeout, $parse) { 
 | 
    return { 
 | 
        restrict: 'A', 
 | 
        link: function ($scope, $elm, $attrs) { 
 | 
            // スマホ用 ロングタップ判定 
 | 
            $elm.bind('touchstart', function (evt) { 
 | 
                // Locally scoped variable that will keep track of the long press 
 | 
                $scope.longPress = true; 
 | 
                var functionHandler = $parse($attrs.onLongPress); 
 | 
                // We'll set a timeout for 600 ms for a long press 
 | 
                $timeout(function () { 
 | 
                    if ($scope.longPress) { 
 | 
                        // If the touchend event hasn't fired, 
 | 
                        // apply the function given in on the element's on-long-press attribute 
 | 
                        $scope.$apply(function () { 
 | 
                            functionHandler($scope, {$event: evt}); 
 | 
                        }); 
 | 
                    } 
 | 
                }, 600); 
 | 
            }); 
 | 
            // スマホ用 タッチ終了 
 | 
            $elm.bind('touchend', function (evt) { 
 | 
                // Prevent the onLongPress event from firing 
 | 
                $scope.longPress = false; 
 | 
                var functionHandler = $parse($attrs.onTouchEnd); 
 | 
                // If there is an on-touch-end function attached to this element, apply it 
 | 
                if ($attrs.onTouchEnd) { 
 | 
                    $scope.$apply(function () { 
 | 
                        functionHandler($scope, {$event: evt}); 
 | 
                    }); 
 | 
                } 
 | 
            }); 
 | 
            // PC用 ロングタップ判定 
 | 
            $elm.bind('mousedown', function (evt) { 
 | 
                // Locally scoped variable that will keep track of the long press 
 | 
                $scope.longPress = true; 
 | 
                var functionHandler = $parse($attrs.onLongPress); 
 | 
                // We'll set a timeout for 600 ms for a long press 
 | 
                $timeout(function () { 
 | 
                    if ($scope.longPress) { 
 | 
                        // If the touchend event hasn't fired, 
 | 
                        // apply the function given in on the element's on-long-press attribute 
 | 
                        $scope.$apply(function () { 
 | 
                            functionHandler($scope, {$event: evt}); 
 | 
                        }); 
 | 
                    } 
 | 
                }, 600); 
 | 
            }); 
 | 
            // PC用 タッチ終了 
 | 
            $elm.bind('mouseup', function (evt) { 
 | 
                // Prevent the onLongPress event from firing 
 | 
                $scope.longPress = false; 
 | 
                var functionHandler = $parse($attrs.onTouchEnd); 
 | 
                // If there is an on-touch-end function attached to this element, apply it 
 | 
                if ($attrs.onTouchEnd) { 
 | 
                    $scope.$apply(function () { 
 | 
                        functionHandler($scope, {$event: evt}); 
 | 
                    }); 
 | 
                } 
 | 
            }); 
 | 
        } 
 | 
    }; 
 | 
}]) 
 | 
; 
 | 
  
 | 
</script> 
 | 
</apex:component> 
 |