Skip to content

Commit

Permalink
added copy favorite url feature
Browse files Browse the repository at this point in the history
  • Loading branch information
mhenke committed Oct 25, 2015
1 parent 46de073 commit 9c91bbb
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 9 deletions.
4 changes: 3 additions & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
"angular-touch": "~1.4.7",
"gsap": "greensock#~1.18.0",
"angular-swing": "*",
"angular-flash-alert": "~1.1.1"
"angular-flash-alert": "~1.1.1",
"zeroclipboard": "~2.2.0",
"ng-clip": "~0.2.6"
},
"resolutions": {
"angular": "~1.3"
Expand Down
4 changes: 3 additions & 1 deletion config/assets/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ module.exports = {
'public/lib/angular-bootstrap/ui-bootstrap-tpls.js',
'public/lib/angular-file-upload/angular-file-upload.js',
'public/lib/owasp-password-strength-test/owasp-password-strength-test.js',
'public/lib/angular-flash-alert/dist/angular-flash.js '
'public/lib/angular-flash-alert/dist/angular-flash.js ',
'public/lib/ng-clip/dest/ng-clip.min.js',
'public/lib/zeroclipboard/dist/ZeroClipboard.js'
],
tests: ['public/lib/angular-mocks/angular-mocks.js']
},
Expand Down
5 changes: 4 additions & 1 deletion config/assets/production.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ module.exports = {
'public/lib/angular-ui-utils/ui-utils.min.js',
'public/lib/angular-bootstrap/ui-bootstrap-tpls.min.js',
'public/lib/angular-file-upload/angular-file-upload.min.js',
'public/lib/owasp-password-strength-test/owasp-password-strength-test.js'
'public/lib/owasp-password-strength-test/owasp-password-strength-test.js',
'public/lib/angular-flash-alert/dist/angular-flash.min.js ',
'public/lib/zeroclipboard/dist/ZeroClipbard.Core.min.js',
'public/lib/zeroclipboard/dist/ZeroClipbard.min.js'
]
},
css: 'public/dist/application.min.css',
Expand Down
2 changes: 1 addition & 1 deletion modules/core/client/app/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
var ApplicationConfiguration = (function () {
// Init module configuration options
var applicationModuleName = 'mean';
var applicationModuleVendorDependencies = ['ngResource', 'ngAnimate', 'ngMessages', 'ui.router', 'ui.bootstrap', 'ui.utils', 'angularFileUpload', 'ngTouch', 'gajus.swing', 'flash'];
var applicationModuleVendorDependencies = ['ngResource', 'ngAnimate', 'ngMessages', 'ui.router', 'ui.bootstrap', 'ui.utils', 'angularFileUpload', 'ngTouch', 'gajus.swing', 'flash', 'ngClipboard'];

// Add a new vertical module
var registerModule = function (moduleName, dependencies) {
Expand Down
20 changes: 16 additions & 4 deletions modules/giphders/client/controllers/giphders.client.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ angular.module('giphders').controller('GiphdersController', ['$scope', '$statePa
// Find a list of Favorites
$scope.findFavorites = function () {
$scope.favorites = Giphders.query(function (response) {
for(var i = 0; i < $scope.favorites.length; i++){
if (i === 0) {
$scope.textToCopy = 'https://media1.giphy.com/media/'+ $scope.favorites[i].giphyid + '/100.gif';
} else {
$scope.textToCopy = $scope.textToCopy + ', https://media1.giphy.com/media/'+ $scope.favorites[i].giphyid + '/100.gif';
}
}
$scope.countFav = $scope.favorites.length;
}, function (errorResponse) {
$scope.errorAlert();
Expand Down Expand Up @@ -84,7 +91,7 @@ angular.module('giphders').controller('GiphdersController', ['$scope', '$statePa
checkElement.remove();
}
$scope.removeAlert();
$scope.countFav = $scope.countFav-1;
$scope.findFavorites();
}, function (errorResponse) {
$scope.errorAlert();
});
Expand All @@ -97,21 +104,26 @@ angular.module('giphders').controller('GiphdersController', ['$scope', '$statePa

$scope.rejectedAlert = function () {
var message = '<strong> Oh Snap!</strong> You rejected the giphy.';
Flash.create('danger', message, 'customAlert');
Flash.create('warning', message, 'customAlert');
};

$scope.errorAlert = function () {
var message = '<strong> Warning!</strong> We are screwed. Something went wrong, very wrong..';
Flash.create('warning', message, 'customAlert');
Flash.create('danger', message, 'customAlert');
};

$scope.removeAlert = function () {
var message = '<strong> You Go, Girl!</strong> You removed the giphy from your favorites.';
Flash.create('info', message, 'customAlert');
Flash.create('warning', message, 'customAlert');
};

$scope.removeAllAlert = function () {
var message = '<strong> That awkward moment,</strong> when you realize you cleared your favorites.';
Flash.create('warning', message, 'customAlert');
};

$scope.copyAlert = function () {
var message = '<strong> Outstanding!</strong> You copied your favorites to clipboard.';
Flash.create('info', message, 'customAlert');
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ <h1>Favorites</h1>
<span flash-message="5000"></span>
<div class="alert alert-info clearfix" ng-if="countFav">
<div class="pull-right">
<button type="button" class="btn btn-info">Share</button>
<input type="hidden" class="form-control" placeholder="Enter text to copy" ng-model="textToCopy">
<button type="button" class="btn btn-info" clip-copy="textToCopy" clip-click="copyAlert()">Share</button>
<button type="button" class="btn btn-danger" ng-click="clearAll()">Clear</button>
</button>
</div>
</div>
</div>
Expand Down

0 comments on commit 9c91bbb

Please sign in to comment.